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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dfahlbusch
    New Member
    • Jul 2010
    • 1

    #1

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

    Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button2.Click
    MessageBox.Show ("2781 Beal St." & Chr(13) & "Deltona, Florida 32763" & Chr(13) & "" & Chr(13) & "View the Property Card?", "Property Address", MessageBoxButto ns.OKCancel)
    If Windows.Forms.D ialogResult.OK Then Process.Start(" IExplore.exe", "http://atlas.vcgov.org/VCMaps/palms/cgisearch.asp?p id=813032250290 ") Else
    End Sub
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    Windows.Forms.D ialogResult.OK is an enumerated value. DialogResult is the datatype. This statement:

    Code:
    If (Windows.Forms.DialogResult.OK) Then ...
    is analogous to:
    Code:
    If (5) Then ...
    Your code needs to be something like the following:

    Code:
    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
      Process.Start("IExplore.exe", "http://atlas.vcgov.org/VCMaps/palms/cgisearch.asp?pid=813032250290")
    Else
      End Sub
    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.

    Comment

    Working...