VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Almost all the Different MsgBox Constants and howto use them

by Jason Ryczek (8 Submissions)
Category: Coding Standards
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (7 Votes)

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.

Rate Almost all the Different MsgBox Constants and howto use them

' 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

Download this snippet    Add to My Saved Code

Almost all the Different MsgBox Constants and howto use them Comments

No comments have been posted about Almost all the Different MsgBox Constants and howto use them. Why not be the first to post a comment about Almost all the Different MsgBox Constants and howto use them.

Post your comment

Subject:
Message:
0/1000 characters