Site hosted by Angelfire.com: Build your free website today!

TUTORIAL 1 OVERVIEW

Lesson 1

Lesson 2
Quiz 2

Lesson 3
Quiz 3

Lesson 4
Quiz 4

Lesson 5
Quiz 5

CHECKPOINT 1

EXTRA INFO

Getting Started with VB6

GUI

Removing the form

Getting to the
Next Lesson

Code Used

Variables and Data Types

Operators

Message Box Info

 

 Message boxes  

MsgBox
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. When the message box has a return value i.e. more that 1 click option. It must be assigned to a variable name. This message box format is as follows:
         

VariableName=MsgBox(“Prompt”, Style , “Title”, )
 
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 Style Values below for types of command button displayed. The Title argument will display the title of the message board.
Style Values

Style Value

Named Constant

Buttons Displayed

0

vbOkOnly

Ok button

1

vbOkCancel

Ok and Cancel buttons

2

vbAbortRetryIgnore

Abort, Retry and Ignore buttons.

3

vbYesNoCancel

Yes, No and Cancel buttons

4

vbYesNo

Yes and No buttons

5

vbRetryCancel

Retry and Cancel buttons

We can use named constant in place of integers for the second argument to make the programs more readable. In fact, VB6 will automatically shows up a list of names constant where you can select one of them.
example:              

VariableName=MsgBox( "Click OK to Proceed", 1, "Startup Menu")

is the same as    

VariableName=Msg("Click OK to Proceed". vbOkCancel, "Startup Menu")

VariableName 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 or Byte data type. The table below shows the values, returned by each of the buttons.

 Return Values


 Value

Named Constant

Button Clicked 

1

vbOk

Ok button

2

vbCancel

Cancel button

3

vbAbort

Abort button

4

vbRetry

Retry button

5

vbIgnore

Ignore button

6

vbYes

Yes button

7

vbNo

No button

To make the message box looks more sophisticated, you can add an icon besides the message. There are four types of icons available in VB as shown below. These commands are added to the style of message box with a + symbol. You can use either the number of the name.
 

Value

Named Constant

Icon 

16

vbCritical

32

vbQuestion

48

vbExclamation

64

vbInformation