NewMaskedEditBox

Description

Adds a masked edit control to a form.

This control generally behaves as a standard text box control with enhancements for optional masked input and formatted output. The input mask prevents you from entering invalid characters into the control.If you define an input mask using the Mask property, each character position in the control maps to either a placeholder of a specified type or a literal character. Literals can give visual cues about the type of data being used. For example, the parentheses surrounding the area code of a telephone number are literals: (206).

Syntax

[Set oCtl =] oFrm.NewMaskedEditBox

( Name, Left, Top, Width, Height, [Container] )

Parameters

Part

Description

Set oCtl =

(optional) Store a reference to the new control in the variable oCtl. This variable can be used to access the control's properties and methods

oFrm

A reference to a form object (see the NewForm method)

Name

The name of the control. It must be unique within the form and may not be empty or start with an asterisk (*)

Left

See the list of properties below

Top

See the list of properties below

Width

See the list of properties below

Height

See the list of properties below

Container

(optional) The name of an existing frame control that will act as container for the textbox. If unspecified or an empty string, the Form itself will be the container. Please note that the Left and Top properties are relative to the container's left and top edges

Properties and Methods

Property

Description

AllowPrompt

(boolean) Determines whether or not the prompt character is a valid input character

AutoTab

(boolean) Determines whether or not the next control in the tab order receives the focus as soon as the control is filled with valid data.

BackColor

Background color (use the RGB function to assign a color value)

BorderStyle

0

None

1

Fixed single (default)

Clipmode

Determines whether to include or exclude the literal characters in the inputmask when doing a cut or copy command

0

(Default) Include literals on a cut or copy command

1

Exclude literals on a cut or copy command

ClipText

Returns the text in the control, excluding literal characters of the inputmask.

Enabled

(boolean) Determines if the control can respond to user-generated events

Fontname

The font used to display text. The default is determined by the system. Check the glossary for an explanation about setting font properties.

Fontsize

The size of the font in points. The maximum is 2160 points.

Fontbold

(boolean) Enable or disable the bold style of a font

Fontitalic

(boolean) Enable or disable the italic style of a font

Fontstrikethru

(boolean) Enable or disable the strikethru style of a font

Fontunderline

(boolean) Enable or disable the underline style of a font

ForeColor

Foreground color (use the RGB function to assign a color value)

Format

Specifies the format for displaying and printing numbers, dates, times, and text. See the attached table

FormattedText

Returns the string displayed in the control when the control doesn't have the focus

Height

The height of the control in twips

Left

The distance from the left edge of the specified container in twips

Mask

Determines the input mask for the control. See the attached table

MaxLength

An integer from 1 to 64 specifying the maximum number of characters a user can enter (including literals in the inputmask) The default is 64

Parent

(read-only) Returns the parent form, object or collection. You can use the parent property to access the properties and methods of an object's parent

PromptChar

Sets or returns the (single) character used to prompt a user for input. The default value is the underscore character (_)

TabStop

(boolean) Determines whether the TAB key can be used to move the focus

Tag

(reserved) Used internally to store the user-defined controlname

Text

Returns or sets the text contained in the edit area of the masked editbox

ToolTipText

Explanatory text that appears in a small rectangle below the object when you pause the mouse pointer (hover) over it for about one second

Top

The distance from the top edge of the specified container in twips

Visible

(boolean) Determines whether the control is visible or hidden

Width

The width of the control in twips

Method

Description

Move

Parameters: left [, top [, width [, height ]]]

Only the left argument is required. However, to specify any other arguments, you must specify all arguments that appear in the syntax before the argument you want to specify. For example, you can't specify width without specifying left and top. Any trailing arguments that are unspecified remain unchanged

Refresh

Forces a complete repaint of a control

SetFocus

Moves the focus to the specified control

Example

Option Explicit

Const vbModal = 1

Dim oDlg, oFrm, oCtl

'Create the WshDialog.Kit object and store a reference in oDlg
Set oDlg = Wscript.CreateObject("WshDialog.Kit", "oDlg_")

'Add a new form and store a reference to it in the variable oFrm
Set oFrm = oDlg.NewForm("Sample")

'Add a label
oFrm.NewLabel "LBL1", 100, 150, 2200, 300, "Enter date (dd-mmm-yy) :"

'Add a masked editbox control named MEX1 and store a reference in the variable oCtl
Set oCtl = oFrm.NewMaskedEditBox("MEX1", 2300, 100, 1500, 300)

'Use the reference variable to set some properties
oCtl.Mask = "##-???-##"
oCtl.Format = "dddddd"

'Add an OK button and set it's Default property
Set oCtl = oFrm.NewButton("OK", 4250, 100, 1000, 375, "&OK")
oCtl.Default = True

'Automatically size the form and show it (modally)
oFrm.Autosize
oFrm.Show vbModal

'Show the date entered in the masked editbox
MsgBox "You entered the following date : " & vbCrlf & vbCrlf & oFrm.Ctl("MEX1").Text