Results 1 to 4 of 4

Thread: [RESOLVED] [2005] Hyperlink/Onclick open page in browser

  1. #1

    Thread Starter
    Lively Member Christineeve's Avatar
    Join Date
    Mar 2006
    Location
    Germany
    Posts
    78

    Resolved [RESOLVED] [2005] Hyperlink/Onclick open page in browser

    It seems when I want something explained in a complex way I find examples that only show the barest of minimum steps, and then the reverse is also true. I've spent several days on this problem too.

    I have one simple hyperlink control and when the user clicks on it, I'd like a browser to open with the page indicated in the control.

    I find all kinds of examples scrolling through this or that or appending text to this or that. I just want to launch a darn page. I've done menus and hyperlinks for years in Access and VB 6.0, I just don't know what I'm doing wrong in VB 2005. Sheesh! Oops, sorry for venting. Any advice would be greatly appreciated, I've already searched high and low, not sure what I'm missing.

    Here is my glamorous code:

    VB Code:
    1. Private Sub llHyperlink_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles llHyperlink.LinkClicked
    2. 'www.microsoft.com is also the text of the hyperlink control.
    3.         Dim url As String = "www.microsoft.com"
    4.          Dim browser As WebBrowser
    5. 'the text must stay white for all states of the click events, "not visited, visited, etc."
    6.  
    7.         browser.Navigate(url)
    8.     End Sub
    Last edited by Christineeve; May 22nd, 2006 at 01:23 PM. Reason: [RESOLVED]
    Christine Lee
    VB '05 Newbie
    Anything but ordinary
    ------------------------------
    Newbie: VB '05 Express Videos:
    http://msdn.microsoft.com/vstudio/ex...g/default.aspx
    My Space! My family!
    http://www.myspace.com/christineeve

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Hyperlink/Onclick open page in browser

    So are you saying that you want to open this page in a new window of the default browser or in a WebBrowser control on your form?

    If it's a WebBroswer control on your form then you need to use a WebBroswer control that's on you form. That code of yours declares a WebBrowser variable but doesn't create a WebBrowser object, and even if it did it isn't added to the form so the user would never see it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member Christineeve's Avatar
    Join Date
    Mar 2006
    Location
    Germany
    Posts
    78

    Re: [2005] Hyperlink/Onclick open page in browser

    Quote Originally Posted by jmcilhinney
    So are you saying that you want to open this page in a new window of the default browser or in a WebBrowser control on your form?

    If it's a WebBroswer control on your form then you need to use a WebBroswer control that's on you form. That code of yours declares a WebBrowser variable but doesn't create a WebBrowser object, and even if it did it isn't added to the form so the user would never see it.
    I'm saying when the user clicks on the hyperlink control, an external webpage opens and displays the website. I definately do not want it to open inside my application.
    Christine Lee
    VB '05 Newbie
    Anything but ordinary
    ------------------------------
    Newbie: VB '05 Express Videos:
    http://msdn.microsoft.com/vstudio/ex...g/default.aspx
    My Space! My family!
    http://www.myspace.com/christineeve

  4. #4

    Thread Starter
    Lively Member Christineeve's Avatar
    Join Date
    Mar 2006
    Location
    Germany
    Posts
    78

    Re: [2005] Hyperlink/Onclick open page in browser

    Ok,

    I finally found this after looking for days. It really couldn't have been easier.

    Thanks for pointing me in the right direction.

    Here's what I did:


    VB Code:
    1. Try
    2.             ' Dim browser As WebBrowser
    3.             System.Diagnostics.Process.Start("http://www.microsoft.com")
    4.  
    5.         Catch ex As Exception
    6.             If Err.Number <> 0 Then
    7.                 errLogger(Err.Number, Err.Description, Err.Source)
    8.             End If
    9.             Exit Sub
    10.         End Try
    Christine Lee
    VB '05 Newbie
    Anything but ordinary
    ------------------------------
    Newbie: VB '05 Express Videos:
    http://msdn.microsoft.com/vstudio/ex...g/default.aspx
    My Space! My family!
    http://www.myspace.com/christineeve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width