|
-
October 8th, 2001, 04:56 PM
#1
MsgBox
My Book is rather vague about the various MsgBox functions. Could someone please Pass along the code to generate a MsgBox with a Yes, No, and Cancel Button and the code to retrieve the response. Thanks RSH
-
October 8th, 2001, 05:28 PM
#2
Re: MsgBox
private Sub Command1_Click()
If MsgBox("This is a message box.", vbYesNoCancel, "The Title") = vbYes then
MsgBox "you clicked yes", vbOKOnly, "Result"
ElseIf MsgBox("This is a message box.", vbYesNoCancel, "The Title") = vbNo then
MsgBox "you clicked No", vbOKOnly, "Result"
End If
End Sub
Thankz, Drew
[email protected]?SUBJECT=I Love Your Stuff
Thanks, Drew
-
October 8th, 2001, 05:52 PM
#3
Re: MsgBox
Heres a similar way
Dim res%
res% = MsgBox("This is a message box.", vbYesNoCancel)
If res% = vbYes Then
MsgBox "you press yes"
ElseIf res% = vbNo Then
MsgBox "you press no"
Else
MsgBox "you pressed cancel"
End If
David Paulson
-
October 8th, 2001, 07:18 PM
#4
Re: MsgBox
Both very good answers.
In the meantime I found another book and came up with this.
Dim Reply
Reply = MsgBox("ARE YOU SHURE YOU WANT TO DELETE THIS FILE", 3, "CAUTION")
If (Reply = 7) Or (Reply = 2) Then Exit Sub
If Reply = 6 Then Goto Blah Blah.
Apperantly the 3 determines the type of box.
73 RSH
-
October 9th, 2001, 01:24 AM
#5
Re: MsgBox
You should use the constant values in stead of the numbers, this will improve readability for yourself, and for anyone who needs to read your code. So instead of using 7,2 or 6, use vbNo, vbCancel and vbYes.
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
October 9th, 2001, 03:08 PM
#6
Re: MsgBox
GO to the Help facility and search on MSGBOX Function. Select VB reference and it will tell all you ever want to know about the MSGBOX Dialog including what the 3 means (Yes,No,Cancel)
John G
-
October 9th, 2001, 06:42 PM
#7
Re: MsgBox
Thanks John:
Ive got it pretty well under control now.
Have tried all the values from 1 to 5
73 RSH
-
October 9th, 2001, 06:46 PM
#8
Re: MsgBox
Sounds reasonable, at least from the readability standpoint. Good suggestion.
73 RSH
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|