VB icon

Almost all the Different MsgBox Constants and howto use them

Email
Submitted on: 1/16/2015 1:02:00 PM
By: Jason Ryczek (from psc cd)  
Level: Beginner
User Rating: By 7 Users
Compatibility: VB 6.0
Views: 528
 
     This is really helpful if you're making a program that asks the user a yes/no question with a message box. That's only one of many great examples. Please Rate.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Almost all the Different MsgBox Constants and howto use them
' Description:This is really helpful if you're making a program that asks the user a yes/no question with a message box. That's only one of many great examples. Please Rate.
' By: Jason Ryczek (from psc cd)
'**************************************

' This works best if you make an array and use the select case statement, but I left it up to the user to do what they want with it.
Dim x as integer ' x = answer value
' For the OKOnly
x = MsgBox("This is Default, Okay Only", vbOKOnly)
' For Ok, cancel
x = MsgBox("Give choice of OK or Cancel", vbOKCancel)
' This is Abort, Retry, Ignore
x = MsgBox("Blow up your computer?", vbAboutRetryIgnore)
' Most Common - :)
x = MsgBox("Would you like to save your dirty pictures before you exit?", vbYesNoCancel)
' Yes or No
x = MsgBox("Was that you or the dog?", vbYesNo)
' Retry or Cancel
x = MsgBox("This is what you might want to do with your diet...", vbRetryCancel)
' Critical Message
x = MsgBox("Your Reports due today and you haven't started on it yet!", vbCritical)
' Question
x = MsgBox("<- Question", vbQuestion)
' now, do decypher the answers
Select Case x
 Case 1:MsgBox "The Okay button"
 Case 2:MsgBox "The Cancel button"
 Case 3:MsgBox "The Abort button"
 Case 4:MsgBox "The Retry button"
 Case 5:MsgBox "The Ignore button"
 Case 6:MsgBox "The Yes button"
 Case 7:MsgBox "The No button"
End Select
' Well, hope that helps all you programmers out there


Other 7 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.