Functionname (Arguments) : Table 12.1: Style Values
Functionname (Arguments) : Table 12.1: Style Values
In this lesson, we are going to learn two very basic but useful internal functions of Visual basic , i.e.
the MsgBox( ) andInputBox ( ) functions.
The objective of MsgBox is to produce a pop-up message box and prompt the user to click on a command
button before he /she can continues. This format is as follows:
The first argument, Prompt, will display the message in the message box. The Style Value will determine
what type of command buttons appear on the message box, please refer ton Table 12.1 for types of
command button displayed. The Title argument will display the title of the message board.
We can use named constants in place of integers for the second argument to make the programs more
readable. In fact, VB6 will automatically shows up a list of named constants where you can select one of
them.
yourMsg is a variable that holds values that are returned by the MsgBox ( ) function. The values are
determined by the type of buttons being clicked by the users. It has to be declared as Integer data type in
the procedure or in the general declaration section. Table 12.2 shows the values, the corresponding
named constant and buttons.
Example 12.1
To make the message box looks more sophisticated, you can add an icon besides the message.
There are four types of icons available in VB2008 as shown in Table 12.3
16 vbCritical
32 vbQuestion
48 vbExclamation
64 vbInformation
Example 12.2
End Sub The first argument, Prompt, will display the messag
An InputBox( ) function will display a message box where the user can enter a value or a message in the
form of text. In VB2005, you can use the following format:
myMessage is a variant data type but typically it is declared as string, which accept the message input by
the users. The arguments are explained as follows:
default-text - The default text that appears in the input field where users can use it as his intended
input or he may change to the message he wish to enter.
x-position and y-position - the position or tthe coordinates of the input box.
However, the format won't work in VB2008 because InputBox is considered a namespace. So, you need to
key in the full reference to the Inputbox namespace, which is
Example 12.3
The inputbox will appear as shown in the figure below when you press the command button
sage box. The Style Value will determine what type of command buttons appear on the message box,
please refer Table 10.1 for types of command button displayed. The Title argument will display the title of
the message board.