Microsoft Office Tutorials and References
In Depth Information
Creating an Input Box
An input box is similar to a message box in that it displays text, but it has the additional func­
tionality of being able to accept text responses from users. Instead of presenting the user with
a few buttons that can be clicked in response to messages displayed in the window, input
boxes contain a text box where the user can type in responses. The input box displays a
prompt and title just as a message box does, but no icons are displayed and an OK and a
Cancel button are always present. An input box that asks for a user’s name would look similar
to Figure 4-15.
Figure 4-15.
Creating an input box would allow users to enter personal information, such as
their name.
The syntax for an input box is shown here.
InputBox ( prompt [, title ][, default ][, xpos ][, ypos ][, helpfile , context ]) as
String
prompt Required argument for the InputBox function that contains the text that is
displayed within the input box. The text can be no longer than about 1024 characters,
depending upon the width of the characters. If the text contains multiple lines, you can
specify the line breaks by including a carriage return with vbCr, a linefeed with vbLf, or
a carriage return/linefeed combination with vbCrLf. You can also use the Visual Basic
intrinsic constants vbCr , vbLf , and vbCrLf to represent the characters.
title Optional string argument used to specify the text to be displayed within the
input boxes title bar. If omitted, “Microsoft Office Excel” is displayed.
default Optional string value that is displayed within the text box as the default value
if no other information is entered. The user can erase or modify the default answer.
xpos Optional numeric expression that represents the number of twips from the left
edge of the screen to the left edge of the input box. If xpos is omitted, the input box is
centered horizontally.
Note A twip (twentieth of a point) is 1/1440th of an inch or 1/567th of a centimeter. So,
to start an input box half an inch in from the left edge of the screen, you would assign an
xpos value of 720.
ypos Optional numeric expression that represents the number of twips from the top
edge of the screen to the top edge of the input box. If ypos is omitted, the input box is
centered vertically.
Search JabSto ::




Custom Search