msgbox.gif (1069 bytes)

Exclamtiub.gif (188 bytes) Message boxes are used to to alert the user with information on a certain syntax that may have occurred, it can be used in a conditional statement, or in its own statement.

 

Call Msgbox(Prompt, Style, Title)

 

!.gif (145 bytes) This is the basic way a message box is set up. You can customize the Prompt,
the Style and the Title, and also use a variable to hold the value, if you use a yes and no button.

boxes.gif (1054 bytes)
Visual Basic provides us with many different styles for our
message boxes, here are some:

msgbox vb style description special picture
vbCrtical OK button and a critical error picture. vbCritical.GIF (242 bytes)
vbExclamation OK button and an exclamation point picture. vbExclimation.gif (232 bytes)
vbInformation OK button and an info picture. vbInfo.gif (236 bytes)
vbOkCancel Ok button and a Cancel button. none
VbOkOnly Ok button, that's it. none
vbQuestion Ok button, with a question picture. vbQuestion.gif (244 bytes)
vbSystemModal Ok button, with a neat icon on the title bar of the msgbox, of a system logo - take a look vbsystemmodal.gif (1164 bytes)
vbYesNo YES and NO button, that's it. none

coding.gif (1526 bytes)

Call Msgbox("Hey Guys - wassup?",vbExclamation,"nauts-crib.com")

Prompt
Style
Title

When It is Executed:

vbExample_1.gif (1285 bytes)


Exclamtiub.gif (188 bytes) Now if you have played around with the message box for a little bit, you will see that It automatically goes to another line if you enter a large prompt. If you want to force vb to make it another line, there is a function that you can add:

VbNewLine


Yes, that's the function, you would use it like this..:

Call Msgbox("Hey" & vbNewLine & "Guys" & vbNewLine & "Wassup?",vbExclamation,"nauts-crib.com")

When Executed:

vb_Example_2.gif (1249 bytes)


how.gif (1937 bytes)
(what button they picked)

 

TheBox =   Msgbox("This is a yes or no vb message box",vbYesNo,"nauts-crib.com")
If TheBox = vbYes then Call Msgbox("You picked yes",vbOkOnly,"nauts-crib.com")
If TheBox = vbNo then call Msgbox(
"You picked no",vbOkOnly,"nauts-crib.com")

The Break Down

1. We set our message box to the variable TheBox (TheBox now holds the value of the button they clicked)
2. We set up a conditional statement, asking vb if the value of TheBox was vbYes, and if it is to send another message box up telling the user they picked yes.
3. We set up another conditional statement, asking vb if the value of TheBox was vbNo, and if it is to send another message box up telling the user they picked no.

 

VB_back.gif (1347 bytes)

1999-2000 © Erik Helgesen All Rights Reserved.
Only permitted Images and Material may be downloaded from this web site. 
PhotoShop, Flash, and Microsoft Visual Basic are registered trademarks!