![]() ![]() Functions (Visual Basic for Applications).MyValue = InputBox(Message, Title, Default, 100, 100) ' Display dialog box at position 100, 100. MyValue = InputBox(Message, Title,, ,, "DEMO.HLP", 10) MyValue = InputBox(Message, Title, Default) ' Display message, title, and default value. ![]() Message = "Enter a value between 1 and 3" ' Set prompt. If the user chooses Cancel, a zero-length string is returned. The variable MyValue contains the value entered by the user if the user chooses OK or presses the ENTER key. If the x and y positions are omitted, the dialog box is automatically centered for the respective axes. This example shows various ways to use the InputBox function to prompt the user to enter a value. To omit some positional arguments, you must include the corresponding comma delimiter. To specify more than the first named argument, you must use InputBox in an expression. If the user pastes text with a line break in the text box, the text is truncated at the line break. The text box does not accept line breaks, such as Shift+Enter. The return string is truncated to 254 characters. The text box accepts only 255 characters. If the user chooses Cancel, the function returns a zero-length string (""). If the user chooses OK or presses ENTER, the InputBox function returns whatever is in the text box. Some host applications, for example, Microsoft Excel, also automatically add a Help button to the dialog box. When both helpfile and context are provided, the user can press F1 (Windows) or HELP (Macintosh) to view the Help topic corresponding to the context. If context is provided, helpfile must also be provided. Numeric expression that is the Help context number assigned to the appropriate Help topic by the Help author. If helpfile is provided, context must also be provided. String expression that identifies the Help file to use to provide context-sensitive Help for the dialog box. If ypos is omitted, the dialog box is vertically positioned approximately one-third of the way down the screen. Numeric expression that specifies, in twips, the vertical distance of the upper edge of the dialog box from the top of the screen. If xpos is omitted, the dialog box is horizontally centered. Numeric expression that specifies, in twips, the horizontal distance of the left edge of the dialog box from the left edge of the screen. If you omit default, the text box is displayed empty. String expression displayed in the text box as the default response if no other input is provided. If you omit title, the application name is placed in the title bar. String expression displayed in the title bar of the dialog box. If prompt consists of more than one line, you can separate the lines by using a carriage return character ( Chr(13)), a linefeed character ( Chr(10)), or carriage return-linefeed character combination (( Chr(13) & ( Chr(10)) between each line. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used. String expression displayed as the message in the dialog box. ![]() The InputBox function syntax has these named arguments: Part Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a String containing the contents of the text box.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |