Text and Password Fields in VBScriptThis page will describe how to use text fields and password fields in your ScriptDialog in VBScript. Create a new VBScript script. Then insert the following code and save it as tut5.vbs. Listing 5.1, tut5.vbs Sub main ' Create the dialog box Set Dialog = CreateObject("TPFSoftware.ScriptDialog") When you run the script, you'll see a dialog box that looks like Figure 5 below. Clicking a button will display a message telling you what you did. Figure 5: Dialog box produced by tut5.vbs.
Analysis For example, the statement... Dialog.AddTextField "ID", "User:", 15, "frank", 12 ...adds a text field named "ID" to the dialog box. The label to the left of the text field is "User:". The text field appears 15 characters wide, and the default value of the field is the text "frank." The final argument specifies the maximum number of characters the user is allowed to type into the field—in this case, 12. To add a password field to a dialog box, use the AddPasswordField method. AddPasswordField takes the same number and types of arguments as AddTextField. To find out what the user typed into a text field or password field, use the ValueOf method which belongs to the Result object. ValueOf takes the name of the field and returns its value. |