|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to check which button was clicked on?Hello,
I have a small Microsoft program, which at the setup time displays the license agreement with OK and Cancel button. I wonder, if there is some mechanism (return code) allowing me to check which button was pressed? Thanks, Fred > I have a small Microsoft program, which at the setup time Although you didn't say, I'm assuming from your use of OK and Cancel > displays the license agreement with OK and Cancel button. > I wonder, if there is some mechanism (return code) allowing me to check > which button was pressed? buttons, that you are displaying your license agreement using a MessageBox with vbOKCancel as your Buttons argument. The key to what you want to do is to use the MsgBox in its function version and assign the user's response to a variable that can be tested (the use of a variable is not required, but my personal opinion is that it makes the code "cleaner"). Generally, you would do something like this... Dim Answer As Long ...... ...... Answer = MsgBox("Text", vbOKCancel + vbExclamation, "License") If Answer = vbOk Then ' Put code here for when the user clicks the OK button Else ' Put code here for when the user clicks the Cancel button End If or, to test in opposite order, do the If..Then..Else part like this... If Answer = vbCancel Then ' Put code here for when the user clicks the Cancel button Else ' Put code here for when the user clicks the OK button End If -- Rick (MVP - Excel)
Vista SP2 Being "offered"
dhRichClient3 Thread Classes Issues VB6 on Vista Home Premium problem Excel Execution from VB Fails on 2nd Attempt Use an Addin to automatically add date/time stamp to each edited line of VB6 code? Sub .... or Private Sub.... Moving .exe somtimes works In High Density Mode - Looking for previous control counting post How to create the project referencing library, which user may not have on his computer? listing all audio devices |
|||||||||||||||||||||||