QTP Descriptive Programs Headline Animator

QTP Descriptive Programs

Friday, October 3, 2008

What is Message Box and Types of Message Box Functions in VB Scripting?

Definition: MsgBox Function is used to display message on Dialog Box, [waits for the user to click a button], and returns a value that indicates which button the user clicked.

Syntax: MsgBox prompt [, buttons] [, title] [, helpfile, context]

Arguments:
Prompt: Message which you want to see on Dialog Box
Buttons: It is a Numeric Values, which specifies number and type of buttons to display and type of icon style to use. If button value is not stated, default value is Zero (0)
Title: Message which you want to see on Title Bar of Dialog Box

MsgBox Function returns one of the following values:

A. 1 = vbOK - OK was clicked
B. 2 = vbCancel - Cancel was clicked
C. 3 = vbAbort - Abort was clicked
D. 4 = vbRetry - Retry was clicked
E. 5 = vbIgnore - Ignore was clicked
F. 6 = vbYes - Yes was clicked
G. 7 = vbNo - No was clicked

Examples:

1. MsgBox "Hello everyone!",0,"Swarup Kumar"
Note: By default the button status is Zero (0)



2. MsgBox "Hello everyone!",1,"Swarup Kumar"



3. MsgBox "Hello everyone!",2,"Swarup Kumar"



4. MsgBox "Hello everyone!",3,"Swarup"



5. MsgBox "Hello everyone!",4,"Swarup Kumar"



6. MsgBox "Hello everyone!",5,"Swarup Kumar"



7. Printing two Message Lines on Dialog Box
MsgBox "Hello"& vbcrlf & "everyone!",1,"Swarup Kumar"



vbcrlf: Visual Basic Carriage Return Line Feed

Guidelines: Instead of 0 to 5 use 16 to 21 to display Critical Icon on Message Box, Use 32 to 37 to display Question Mark Icon on Message Box, Use 48 to 53 to display Question Mark Icon on Message Box, Use 64 to 69 to display Information Icon on Message Box

1 comment:

Anonymous said...

Thank for sharing this. It is very helpful.