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)

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.

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. |
vbExclamation | OK button and an exclamation point picture. |
vbInformation | OK button and an info picture. |
vbOkCancel | Ok button and a Cancel button. | none
VbOkOnly | Ok button, that's it. | none
vbQuestion | Ok button, with a question picture. |
vbSystemModal | Ok button, with a neat icon on the title bar of the msgbox, of a system logo - take a look |
vbYesNo | YES and NO button, that's it. | none

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

Prompt
Style
Title

When It is Executed:

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:

(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.

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!