Unit I-VB Controls, Messagebox, Input Box
Unit I-VB Controls, Messagebox, Input Box
.
Sample Application – Addition of Two numbers
Frame Properties:
Caption Title information at top of frame.
Font Sets font type, style, size.
Frame Control
Message Box ( ) Function
• Displays a message in a dialog box and wait for the user to click a button, and
returns an integer indicating which button the user clicked.
Syntax :
MsgBox ( Prompt [,icons+buttons ] [,title ] )
memory_variable = MsgBox ( prompt [, icons+ buttons] [,title] )
• Prompt : String expressions displayed as the message in the dialog box.
• Icons + Buttons : Numeric expression that is the sum of values specifying the number and type of
buttons and icon to display.
• Title : String expression displayed in the title bar of the dialog box.
Message Box () Function Contd…
ICONS
Message Box () Function Contd…
Buttons
Constant Value Description
vbOkOnly 0 Display OK button only
vbOkCancel 1 Display OK and Cancel
vbAbortRetryIgnore2 Display Abort, Retry and Ignore
vbYesNoCancel 3 Display Yes, No and Cancel buttons
vbYesNo 4 Display Yes and No buttons
vbRetryCancel 5 Display Retry and Cancel
Message Box Contd…
Return Values
Constant Value Description
vbOk 1 Ok Button
vbCancel 2 Cancel Button
vbAbort 3 Abort Button
vbRetry 4 Retry Button
vbIgnore 5 Ignore Button
vbYes 6 Yes Button
vbNo 7 No Button
Message Box () Function Contd…
• MsgBox("Click to Test", vbYesNoCancel + vbExclamation, "TestMessage")
Message Box () Function Contd…
• MsgBox ("No names is selected", vbInformation, "Error“)
• answer = MsgBox("Are you sure you want to delete " ,vbCritical + vbYesNo, "Warning")
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: