Search Tools Links Login

Almost all the Different MsgBox Constants and howto use them

Posted: 2002-06-01
By: ArchiveBot
Viewed: 88

Filed Under:

Visual Basic 6

No attachments for this post

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.

Original Author: Jason Ryczek


' 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

Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.