InputBox Function


InputBox Function

Class

Microsoft.VisualBasic.Interaction

Syntax

     Dim result As String = InputBox  (prompt[, title[, _     defaultResponse[, xpos[, ypos]]]]) 


prompt (required; String)

A message displayed in the body of the dialog box that usually emphasizes the type of data to be entered. May include line termination characters.


title (optional; String)

The text to display in the title bar of the dialog box. If omitted or blank, the name of the application is used.


defaultResponse (optional; String)

String to be displayed in the text box when the dialog box first opens. This may be an empty string.


xpos (optional; Numeric)

The distance in twips from the left-hand side of the screen to the left-hand side of the dialog box. If omitted, the dialog box is centered horizontally.


ypos (optional; Numeric)

The distance in twips from the top of the screen to the top of the dialog box. If omitted, the dialog box is positioned vertically about one-third of the way down from the top of the screen.

Description

The InputBox function displays a dialog box containing a prompt for the user, a text box for entering data, and OK and Cancel buttons. When the user clicks OK, the function returns the contents of the text box. If the user clicks the Cancel button, an empty string ("") is returned.

Usage at a Glance

  • It is not possible to distinguish between a click on the OK button with a blank text field and a click on the Cancel button.

  • prompt can contain approximately 1,000 characters, including nonprinting characters such as the intrinsic vbCrLf constant.

  • If you are omitting one or more of the optional arguments and are using subsequent arguments, you must use a comma to signify the missing parameter. For example, the following code fragment displays a prompt and a default string in the text box; default values will be used for the title and for dialog box positioning.

         Dim userResponse As String     userResponse = InputBox("Enter the data", , "The Data") 

  • InputBox always returns a string. Your code is responsible for converting it to the required data type before use.

See Also

MsgBox Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net