Input Boxprompt[ title[ default[ xpos[ ypos

The InputBox() function displays a dialog box with a prompt and a TextBox control and waits for the user to enter some text and click the OK or Cancel button. The arguments of the InputBoxQ function are shown in Table 2.

Table 2: Arguments of the InputBox() function argument what it is prompt The prompt that appears in the dialog box title The title of the dialog box default The default input (if any)

xpos, ypos The coordinates of the top-left corner of the dialog box

Description

If necessary, the prompt is broken into multiple lines automatically. To control line breaks from within your code, use a carriage return character or a linefeed character (vbCr, vbLf).

If you omit this argument, the application's name is displayed as the title.

If you anticipate the user's response, use this argument to display it when the dialog box is first opened.

Expressed in twips.

The simplest format of the InputBoxQ function is as follows: SSN = InputBox("P1ease enter your social security number")

The string that the user enters in the dialog box is assigned to the variable SSN. The return value is always a string, even if the user enters numeric information. When prompting for input with the InputBox() function, always check the value returned by the function. At the very least, check for a blank string. Use the IsNumericQ function if you expect the user to enter a number, use the IsDateQ function if you expect the user to enter a date, and so on.

BDay = InputBox("P1ease enter your birth date") If IsDate(BDay) Then

MsgBox("Preparing your horoscope") Else

MsgBox("P1ease try again with a valid birth date") End If

0 0

Post a comment