0% found this document useful (0 votes)
2 views

Q3 Lesson 1_ InputBox and MsgBox

input

Uploaded by

JADE ELLONE Lara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Q3 Lesson 1_ InputBox and MsgBox

input

Uploaded by

JADE ELLONE Lara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Introduction to Visual

Basic Programming
Quarter 3: Week 2
Lesson 2.2:

Commonly Used
Function:
InputBox
Specific Learning Objectives
At the end of the lesson, you should be able to:

Define Know the Determine the Design and code


what an different parts syntax of an a simple
InputBox is; of an InputBox; InputBox; and application
using InputBox.

3
When you are using your computer, do
you see some of this?

4 4
Lesson 2.2:

What are
InputBox?
InputBox
Displays a prompt in a dialog box,
waits for the user to input text or
click a button, and returns a String
containing the contents of the text
box.

Example
Title Bar

Prompt Default Value


InputBox Syntax:
variable=InputBox(Prompt, Title,
default_text, x-position, y-position)
Example
Title Bar
• Prompt – a string expression
displayed in the dialog box.
• Title – a string expression
displayed in the title bar of the
dialog box. If you omit the title,
the application/project name is
displayed.
Prompt Default Value
• Default-text – It is the text that
appears in the input field.
• X and Y position – the position
or the coordinate of the input
box.
Private Sub btnInputBox_Click(sender As Object, e As EventArgs) Handles
btnInputBox.Click

Dim name As String

name = Microsoft.VisualBasic.Interaction.InputBox("Please Input fullname",


"Example of InputBox", "Type here", 3, 5)
lblname.Text = name
End Sub
Private Sub btnInputBox_Click(sender As Object, e As EventArgs) Handles btnInputBox.Click

Dim name As String

name = Microsoft.VisualBasic.Interaction.InputBox("Please Input fullname",


"Example of InputBox", "Type here", 43, 55)
lblname.Text = name
End Sub
Lesson 2.3:

Commonly Used
Function:
MsgBox
Specific Learning Objectives
At the end of the lesson, you should be able to:

Define Know the Determine the Design and code


what a Msg different parts syntax of a a simple
Box is; of a Msg Box; MsgBox; and application
using MsgBox.

11
When you are using your computer, do
you see some of this?

12 12
How are the previous images different
from Input Boxes?

13 13
Lesson 2.3:

What are
MsgBox?
MsgBox
It 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.

Example
Title Bar

Icon Prompt Buttons


MsgBox Syntax:
name = MsgBox("Do you want to run
Macro1?", vbQuestion + vbYesNo,
"Microsoft Excel")
memory_variable = MsgBox (
Prompt, icons+buttons, title )
• Prompt – a string expression
displayed in the dialog box.
• Title – a string expression
displayed in the title bar of the
dialog box. If you omit the title,
the application/project name is
displayed.
• icons+buttons – Numeric
expression that is the sum of the
values specifying the number
and type of buttons and icon to
display.
List of Icons you can use in a MsgBox:

Icons Value Description Example


Message Box : Icons

vbCritical 16 Critical Message Icon

vbQuestion 32 Warning Query Icon

vbExclamation 48 Warning Message Icon

vbInformation 64 Information Icon


Buttons & Return Values List of Buttons you can use in a MsgBox:
Icons Value Description
vbOkOnly 0 Ok button only
vbOkCancel 1 Ok and Cancel buttons
vbAbortRetryIgnore 2 Abort, Retry, and Ignore buttons
vbYesNoCancel 3 Yes, No, and Cancel buttons
vbYesNo 4 Yes and No Buttons
vbRetryCancel 5 Retry and Cancel Buttons

Return Values:
Icons 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
Example:
Buttons & Return Values
Sample = MsgBox ( “Do you want to run Macro1?” , vbQuestion + vbYesNo,
“Microsoft Excel” )
Sample = MsgBox ( “Do you want to run Macro1?” , 32 + 4, “Microsoft Excel” )

You might also like