By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,521 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,521 IT Pros & Developers. It's quick & easy.

Using a message box to open a web page. Problem, page always opens, even on CANCEL

P: 1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MessageBox.Show("2781 Beal St." & Chr(13) & "Deltona, Florida 32763" & Chr(13) & "" & Chr(13) & "View the Property Card?", "Property Address", MessageBoxButtons.OKCancel)
If Windows.Forms.DialogResult.OK Then Process.Start("IExplore.exe", "") Else
End Sub
Jul 21 '10 #1
Share this Question
Share on Google+
1 Reply

Joseph Martell
Expert 100+
P: 196
Windows.Forms.DialogResult.OK is an enumerated value. DialogResult is the datatype. This statement:

Expand|Select|Wrap|Line Numbers
  1. If (Windows.Forms.DialogResult.OK) Then ...
is analogous to:
Expand|Select|Wrap|Line Numbers
  1. If (5) Then ...
Your code needs to be something like the following:

Expand|Select|Wrap|Line Numbers
  1. If (MessageBox.Show("2781 Beal St." & Chr(13) & "Deltona, Florida 32763" & Chr(13) & "" & Chr(13) & "View the Property Card?", "Property Address", MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK) Then
  2.   Process.Start("IExplore.exe", "")
  3. Else
  4.   End Sub
  5. End If
You are trying to test the user's response to the dialog box which is returned as a DialogResult type from the Show method.

Also, putting your examples in code tags helps with readability tremendously. Just a recommendation for the future.
Jul 23 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.