Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello All,

 

If I have a MessageBox with an 'Ok' and a 'Cancel', how do I create a function (or method) for each of these buttons?

 

e.g. If I press 'Ok' it will access the new form and if I press 'Cancel' it remains in the form from which the button was originally pressed.

 

Any help will be very much appreciated.

 

Thanks,

Harold Clements

  • Leaders
Posted

Save yourself a couple lines of code. I think these would also be easier to read.

       Select Case MessageBox.Show("Message", "Caption", MessageBoxButtons.OKCancel)
           Case DialogResult.OK
               'Code here
           Case DialogResult.Cancel
               'Code here
       End Select
       '-------OR--------'
       If MessageBox.Show("Message", "Caption", MessageBoxButtons.OKCancel) = DialogResult.OK Then
           'Code here
       Else 'User clicked Cancel
           'Code here
       End If

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...