|
-
Nov 11th, 2003, 03:23 PM
#1
Thread Starter
Addicted Member
MsgBox results?
how do i find out what button was pressed on a message box? here is the code i have:
VB Code:
MsgBox "This scene has been changed. Do you want to save changes?", vbYesNo, "Save Changes"
but how do i get what button (either the yes or the no button) was pressed?
-
Nov 11th, 2003, 03:27 PM
#2
Like:
VB Code:
If MsgBox("This scene has been changed. Do you want to save changes?", vbYesNo, "Save Changes") = vbYes Then
'Yes was presssed
End If
Bruce.
-
Nov 11th, 2003, 03:29 PM
#3
Lively Member
Code:
iAnswer = MsgBox("Do you want to continue?", vbYesNo, "Continue")
If iAnswer = vbYes then
Continue
End if
-
Nov 11th, 2003, 03:36 PM
#4
PowerPoster
Well
And another :
VB Code:
Select Case MSGBOX("Continue?",VbQuestion+VBYesNo)
Case vbYes
Case vbNo
End Select
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Nov 11th, 2003, 03:48 PM
#5
Supreme User
I use this way:
VB Code:
Dim Response As Integer
Response = MsgBox "This scene has been changed. Do you want to save changes?", vbYesNo, "Save Changes"
if Response = vbYes then
'Code here
else if Response = vbNo then
'Code here
end if
-
Nov 11th, 2003, 05:53 PM
#6
Fanatic Member
ahh heck lets combinine a couple ways into the way I do it 
VB Code:
iAnswer = Msgbox("Whatever", vbYesNo, "Whatever")
Select case iAnswer
Case vbYes
'Yes Code
Case vbNo
'No Code
end select
The reason for this is you may need to know your answer again later in some coding situations .. never know hehe..
-
Nov 11th, 2003, 06:24 PM
#7
Conquistador
VB Code:
Dim Response As VbMsgBoxResult
Response = MsgBox("hi :D", vbYesNo)
Technically, and seeing as we're flogging the dead horse out of a problem that could've been answered by one person or even a simple search (!), i thought i'd post it
-
Nov 12th, 2003, 12:04 AM
#8
PowerPoster
how do i find out what button was pressed on a message box? here is the code i have:
each msgbox arguments has return values. vb assigns these values to the buttons in your message box.
Code:
If(msgbox("Are you sure you want to Quit?"?, vbYesNO)=vbYes) then
msgbox("You Clicked YES")
else
msgbox("You Clicked NO")
end if
MsgBox Return Values:
vbOK=1, vbCancel = 2,vbAbort=3, vbRetry =4,vbIgnore = 5, vbYes = 6, vbNo =7
Last edited by Simply Me; Nov 12th, 2003 at 03:29 AM.
-
Nov 12th, 2003, 01:19 AM
#9
Frenzied Member
Originally posted by da_silvy
VB Code:
Dim Response As VbMsgBoxResult
Response = MsgBox("hi :D", vbYesNo)
how do i get the icon in the message box???
-
Nov 12th, 2003, 06:18 AM
#10
You cant 
I would always use the same method as JamesStanich:
VB Code:
Select Case MsgBox("Save changes?", vbQuestion + vbYesNoCancel, "My App")
Case vbYes
Case vbNo
Case vbCancel
End Select
No need for any 3rd party varibles and the code is easily changed to handle more or less return values.
However, if if were just for a yes or no answer then I would use:
VB Code:
If MsgBox("Save changes?", vbQuestion + vbYesNo, "My App") = vbYes Then
Else
End If
Woka
-
Nov 13th, 2003, 08:57 AM
#11
Conquistador
I seriously cannot believe that there are 9 (10 now) replies to this thread!
what a joke
-
Nov 13th, 2003, 09:09 AM
#12
How do I change the text of a label? 
Woka
-
Nov 13th, 2003, 09:23 AM
#13
Hyperactive Member
Originally posted by Wokawidget
How do I change the text of a label? 
Woka
label.text = "changed"
-
Nov 13th, 2003, 09:31 AM
#14
Frenzied Member
another way
VB Code:
If Not MsgBox("yes or no?!?", vbYesNo) = vbYes Then
'NO
Else
'YES
End If
-
Nov 13th, 2003, 09:41 AM
#15
Originally posted by spoiledkid
label.text = "changed"
Vb gives me an error:
"Method or data member not found"
I am really stuck. This project has to be finished by the end of the day...*sob*
Or another MsgBox method:
VB Code:
If Not (Not MsgBox("yes or no?!?", vbYesNo) = vbYes) Then
'YES
Else
'NO
End If

Woka
-
Nov 13th, 2003, 09:53 AM
#16
Lively Member
lable.caption = "changed"
-
Nov 13th, 2003, 09:59 AM
#17
Hyperactive Member
Originally posted by KMcKenzie
lable.caption = "changed"

Boy, we really can drag the length of this thread to as long as we like ....
-
Nov 13th, 2003, 10:16 AM
#18
Hahahahaha...It does't work for me...still get the same error 
Anyways, this will get moved to chit-chat if we ain't careful and to be fair I think everything about returning the response from a MsgBox has been covered so I am gonna go and find another thread to violate in a rather rude way...badger styleeeeee 
Adios,
Woka
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
|