MessageBox Buttons

haroldjclements

Freshman
Joined
Jun 13, 2004
Messages
46
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
 
Save yourself a couple lines of code. I think these would also be easier to read.
Visual Basic:
        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
 
Back
Top