Examining InputBox()You'll find that the InputBox() function is easy because it acts much like the MsgBox() function. The InputBox() function receives answers that are more complete than the MsgBox() function can get. Whereas MsgBox() returns one of seven values that indicate the user's command button press, the InputBox() function returns a string data value that holds the answer typed by the user. Here is the format of the InputBox() function: strVariable = InputBox( strprompt [, [strTitle] [, strDefault] [, intXpos, intYpos]]]) strPrompt works a lot like the strmsg value in a MsgBox() function. The user sees strPrompt inside the input box displayed onscreen. strTitle is the title inside the input box's title bar. strDefault is a default string value that Visual Basic displays for a default answer, and the user can accept the default answer or change the default answer. The intXpos and intYpos positions indicate the exact location where you want the input box to appear on the form. The intXpos value holds the number of twips from the left edge of the Form window to the left edge of the input box. The intYpos value holds the number of twips from the top edge of the Form window to the top edge of the input box. If you omit the intXpos and intYpos values, Visual Basic centers the message box on the form.
The following statement displays an input box that asks the user for a company name. The user either enters a response to the prompt or clicks the Cancel command button to indicate that no answer is coming: strCompName = InputBox("What is the name of the company?", "Company Request", "XYZ, Inc.") ![]() You can offer a default answer that the user can accept or change in the strDefault argument. The input box function returns the answer to the string variable to which you assign the function.
The InputBox () function is used to ask a question from the user. |
|
![]() |
![]() |
|||