Page 135 - Excel Progamming Weekend Crash Course
P. 135

h540629 ch09.qxd  9/2/03  9:33 AM  Page 110




                110                                                         Saturday Morning

                          If you do not care about the value returned by the MsgBox function, you can
                          simply ignore it — in other words, call MsgBox like a sub procedure.
                   Tip


               InputBox Function
               The InputBox function displays a dialog box with a prompt and an entry field where the
               user can enter text. The text entered by the user is returned to the calling program. Figure
               9-2 shows an example.










                    Figure 9-2 The dialog box displayed by the InputBox function
                  The syntax of the InputBox function is:
                  InputBox(prompt, title, default, xpos, ypos, helpfile, context)

                   Prompt. The prompt displayed in the dialog box.
                   Title. A string specifying the dialog box title (displayed in the title bar). Optional.
                   If omitted, the name of the application is used.
                   Default. The text displayed in the entry field when the dialog box is first displayed.
                   Optional; the default is an empty string.
                   Xpos, ypos. Numerical values specifying the position of the dialog box relative to
                   the upper left corner of the screen. The units are twips, with 1,440 twips per inch.
                   Both arguments are optional. If xpos is omitted, the dialog box is centered horizon-
                   tally. If ypos is omitted, the dialog box is positioned about one-third of the way
                   from the top of the screen.
                   HelpFile. The name of the help file that provides context-sensitive help for the
                   dialog box (activated by pressing F1). Optional argument.
                   Context. The context identifier for the dialog box’s context-sensitive help.
                   Optional. If the HelpFile argument is provided, context must be provided as well
                   (and vice versa).
                  This example uses the InputBox function to get the user’s favorite flavor of ice cream,
               with “Chocolate” as the default response:
                  flavor = InputBox(“Your favorite flavor?”, “Ice cream”, “Chocolate”)

                          Sessions 19–22 show you how to use User Forms for more sophisticated data
                          entry tasks than are possible with InputBox.
                 Cross-Ref
   130   131   132   133   134   135   136   137   138   139   140