-
1) I've got a msgbox with 2 button, ok and cancel. I want the ok button to unload everything (i.e. itself and the main form) and the cancel button just to unload itself(msgbox) and go back into the mainform. My Code so far is: msgbox "hello",vbOKCancel...(then what?!) I hope you underdstood that! (Please can you give me an e.g line as I'm fairly new to VB6)
2) How do you change the names of the buttons on the msgbox? (Please can you give me an e.g line as I'm fairly new to VB6)
Thank you very much
moonfruit
-
well, if you call the MsgBox function with:
Code:
x = MsgBox ("Press a button", vbOkCancel, "Title")
with any types of buttons you like, you can then do:
Code:
Select Case x
Case vbOK 'OK was pressed
'Your code here
Case vbCancel 'Cancel was pressed
'Your code here
Case vbAbort 'Abort was pressed
'Your code here
Case vbRetry 'Retry was pressed
'Your code here
Case vbIgnore Ignore was pressed
'Your code here
Case vbYes 'Yes was pressed
'Your code here
Case vbNo 'No was pressed
'Your code here
End Select
hope that helps..
-
I don't know how to change the name of the button, there must be a way,but for now u can do a form that look like a message box, then you would be able to do what ever you want with it.:p
-
Message Box
Your code should look like this:
Private Sub Command1_Click() 'COMMAND BUTTON CLICK EVENT
If MsgBox("Hello", vbExclamation Or vbOKCancel, _
"Exit") = vbOK Then
Unload Me 'UNLOADS THE FORM
End If
End Sub
If the cancel button is pressed, nothing will happen.
The "vbExclamation" tells it to show the yellow exclamation point icon and "vbOKCancel" gives you the OK and Cancel buttons. You must use "Or" between these. "And" makes more sense, but will not work.
You can use "vbCritical Or vbOKCancel". This shows the red X icon and OK and Cancel Buttons. There are several Icon and button choices. Just play around with it.