Simple message boxes can be made to pop up with information for the user by use of the msgBox command.
For example, this line:
MsgBox "Have a nice day!", , "Greeting"
would produce this message box:

You can also add icons to catch the user's attention by putting a number between the message and the title bar text
![]() |
Critical Message
MsgBox "Have a nice day!", 16, "Greeting" |
![]() |
Warning Query
MsgBox "Have a nice day!", 32, "Greeting" |
![]() |
Warning Message
MsgBox "Have a nice day!", 48, "Greeting" |
![]() |
Information Message
MsgBox "Have a nice day!", 64, "Greeting" |
![]() |
|
Input Boxes
An InputBox( ) function will display a message box where the user can enter a value or a message in the form of text. The user's input is stored in a variable. The format isvariable = InputBox("Prompt", "Title")
So for example, userName = InputBox("What is your name?", "Title") would pop up this input box

Whatever the user types would be stored in the variable called userName.
We will create a simple application that asks the user's name, then responds to them:
Set up an interface like this:

Write the code:
| Private Sub cmdGreeting_Click() Dim userName As String userName = InputBox("What is your name?", "Greeting") MsgBox "Hello " & userName, 64, "Greeting" End Sub |
The input box line stores the user's name in the variable called userName
The message box line uses the & operator to join the word 'Hello' to whatever is stored in userName
![]() |
|
![]() |
|










