Back
In this section, two communication methods between you and your computer. The Message Box and the Input Box objets will facilitate a exchange of information between you and your computer. The Message Box is a VBA objet that display a message given to you by the computer, while an Input Box is a VBA objet to give information from the user to the computer.
= The Syntax of the Message Box is the following :
Msg = "[message]" & InpMsg
= The Syntax of the Input Box is the following :
InpMsg = Application.InputBox("[message]")
EXAMPLES OF MESSAGES AND INPUT BOXES
Hereafter, an example of a Message Box, and an example of an Input Box. As you can see, the Message Box display a message on the screen in order to inform the user of the computer abour something. In the case of the Input Box, the computer is waiting some information from the user, in order to integrate this new information in the ongoing process.
ROUTINES
The following routine represents a Click Button, if you click on the button, this routine will call execute the subroutine Sellama [1]. The next one displays an InputBox, then a Message box. If you click on "No", then the routine displays " Oooops! Does´nt matter", if you click on "Yes", the routine will display ""¡I must be a fortune teller!", then click on "Ok" to end [2].
Never forget that you have to be always able to identify rapidly where are the beginning and the end of a sub routine. in the case of the command button, the sub routine begins with [Private Sub], and ends with [End Sub]. The second routine begins with [Public Sub] and ends with [End Sub], following the same patterns than the first sub routine.
[1]--------------------------------------------------------
Private Sub CommandButton1_Click()
Sellama
End Sub
[2]--------------------------------------------------------
Public Sub Sellama()
InpMsg = Application.InputBox("What is the name")
Msg = "The Name is " & InpMsg
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then MsgBox "Oooops! Does´nt matter"
Else MsgBox "¡I must be a fortune teller!"
End If
End Sub
-----------------------------------------------------------
PICTURE 1
Hereafter, you will find a visual interpretation of the functions of respectively, the input and the message Boxes.
In this section, two communication methods between you and your computer. The Message Box and the Input Box objets will facilitate a exchange of information between you and your computer. The Message Box is a VBA objet that display a message given to you by the computer, while an Input Box is a VBA objet to give information from the user to the computer.
= The Syntax of the Message Box is the following :
Msg = "[message]" & InpMsg
= The Syntax of the Input Box is the following :
InpMsg = Application.InputBox("[message]")
EXAMPLES OF MESSAGES AND INPUT BOXES
Hereafter, an example of a Message Box, and an example of an Input Box. As you can see, the Message Box display a message on the screen in order to inform the user of the computer abour something. In the case of the Input Box, the computer is waiting some information from the user, in order to integrate this new information in the ongoing process.
ROUTINES
The following routine represents a Click Button, if you click on the button, this routine will call execute the subroutine Sellama [1]. The next one displays an InputBox, then a Message box. If you click on "No", then the routine displays " Oooops! Does´nt matter", if you click on "Yes", the routine will display ""¡I must be a fortune teller!", then click on "Ok" to end [2].
Never forget that you have to be always able to identify rapidly where are the beginning and the end of a sub routine. in the case of the command button, the sub routine begins with [Private Sub], and ends with [End Sub]. The second routine begins with [Public Sub] and ends with [End Sub], following the same patterns than the first sub routine.
[1]--------------------------------------------------------
Private Sub CommandButton1_Click()
Sellama
End Sub
[2]--------------------------------------------------------
Public Sub Sellama()
InpMsg = Application.InputBox("What is the name")
Msg = "The Name is " & InpMsg
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then MsgBox "Oooops! Does´nt matter"
Else MsgBox "¡I must be a fortune teller!"
End If
End Sub
-----------------------------------------------------------
PICTURE 1
Hereafter, you will find a visual interpretation of the functions of respectively, the input and the message Boxes.