90 likes | 341 Views
Input and Message Boxes. InputBox() Function. An input box is a dialog box that opens and waits for the user to enter information. Syntax: InputBox(prompt[,title][,default]) Returns a string containing the contents of the text box. InputBox() Example. Dim strMessage As String
E N D
InputBox() Function • An input box is a dialog box that opens and waits for the user to enter information. • Syntax: • InputBox(prompt[,title][,default]) • Returns a string containing the contents of the text box
InputBox() Example • Dim strMessage As String • Dim strTitle As String • Dim strDefault As String • Dim strInput As String • strMessage = “Enter a value between 1 and 3” • strTitle = “InputBox Demo” • strDefault = “1” • strInput = InputBox(strMessage,strTitle,strDefault)
MsgBox()Function • displays a message for the user to read • returns a value that indicates which command button the user selected • useful for program debugging
MsgBox Syntax • Syntax: • MsgBox(prompt[,buttons][,title]) • The prompt is the only mandatory argument. This is the message that is displayed in the message box.
Buttons argument settings • The first group of values (0 – 5) describes the number and type of buttons displayed in the dialog box. • The second group (16, 32, 48, 64) describes the icon style. • The third group (0, 256, 512) determines which button is the default. • The fourth group (0, 4096) determines the modality of the message box.
MsgBox Example • Dim strMsg, strTitle As String • Dim intStyle, intResponse As Integer • strMsg = "Do you want to continue ?” • intStyle = vbYesNo + vbCritical + vbDefaultButton2 • strTitle = "MsgBox Demonstration" • intResponse = MsgBox(strMsg, intStyle, strTitle) • lblResponse.Caption = intResponse