Open a browser & link to a specific Website.

Hi guys and girls,

I have a form with a lit of website addesses listed in labels (or text boxes or radio buttons if it's easier).

What I need some code to do is when the link (lable) is clicked it opens up a IE or default web browser straight to that specific link.

Can anyone please help ?

Thanks in advance.

Comments

  • Quite simple really. Put a 5 button Option Button array and 1 Web Browser control on a Form and then just paste in this code.

    The URL's for the sites are stored in the Option Buttons' Caption Property and as soon as one of them is clicked, the Browser is directed to that URL.

    [code]
    Private Sub Option1_Click(Index As Integer)
    Select Case Index
    Case 0
    WebBrowser1.Navigate (Option1(0).Caption)
    Case 1
    WebBrowser1.Navigate (Option1(1).Caption)
    Case 2
    WebBrowser1.Navigate (Option1(2).Caption)
    Case 3
    WebBrowser1.Navigate (Option1(3).Caption)
    Case 4
    WebBrowser1.Navigate (Option1(4).Caption)
    End Select
    End Sub
    [/code]
  • : Quite simple really. Put a 5 button Option Button array and 1 Web Browser control on a Form and then just paste in this code.
    :
    : The URL's for the sites are stored in the Option Buttons' Caption Property and as soon as one of them is clicked, the Browser is directed to that URL.
    :
    : [code]
    : Private Sub Option1_Click(Index As Integer)
    : Select Case Index
    : Case 0
    : WebBrowser1.Navigate (Option1(0).Caption)
    : Case 1
    : WebBrowser1.Navigate (Option1(1).Caption)
    : Case 2
    : WebBrowser1.Navigate (Option1(2).Caption)
    : Case 3
    : WebBrowser1.Navigate (Option1(3).Caption)
    : Case 4
    : WebBrowser1.Navigate (Option1(4).Caption)
    : End Select
    : End Sub
    : [/code]
    :
    Thanks I will do this tonight ............ onwards and upwards.
  • : Quite simple really. Put a 5 button Option Button array and 1 Web Browser control on a Form and then just paste in this code.
    :
    : The URL's for the sites are stored in the Option Buttons' Caption Property and as soon as one of them is clicked, the Browser is directed to that URL.
    :
    : [code]
    : Private Sub Option1_Click(Index As Integer)
    : Select Case Index
    : Case 0
    : WebBrowser1.Navigate (Option1(0).Caption)
    : Case 1
    : WebBrowser1.Navigate (Option1(1).Caption)
    : Case 2
    : WebBrowser1.Navigate (Option1(2).Caption)
    : Case 3
    : WebBrowser1.Navigate (Option1(3).Caption)
    : Case 4
    : WebBrowser1.Navigate (Option1(4).Caption)
    : End Select
    : End Sub
    : [/code]
    :
    ok I tried this and it does go to the website in the browser control. What I wanted to do was make my app open IE or the default browser on the users computer so they have print, back, forward facilties etc.

    So User click on the option (or from the list on the menu) and it opens IE on the specifice page.
  • : : Quite simple really. Put a 5 button Option Button array and 1 Web Browser control on a Form and then just paste in this code.
    : :
    : : The URL's for the sites are stored in the Option Buttons' Caption Property and as soon as one of them is clicked, the Browser is directed to that URL.
    : :
    : : [code]
    : : Private Sub Option1_Click(Index As Integer)
    : : Select Case Index
    : : Case 0
    : : WebBrowser1.Navigate (Option1(0).Caption)
    : : Case 1
    : : WebBrowser1.Navigate (Option1(1).Caption)
    : : Case 2
    : : WebBrowser1.Navigate (Option1(2).Caption)
    : : Case 3
    : : WebBrowser1.Navigate (Option1(3).Caption)
    : : Case 4
    : : WebBrowser1.Navigate (Option1(4).Caption)
    : : End Select
    : : End Sub
    : : [/code]
    : :
    : ok I tried this and it does go to the website in the browser control. What I wanted to do was make my app open IE or the default browser on the users computer so they have print, back, forward facilties etc.
    :
    : So User click on the option (or from the list on the menu) and it opens IE on the specifice page.
    :
    OK, in that case you'll need to make an API call.

    Paste this function into your project:
    [code]
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hWnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long
    [/code]

    Then call it with:

    [code]
    Private Sub Option1_Click(Index As Integer)
    Select Case Index
    Case 0
    ShellExecute Me.hWnd, "open", Option1(0).Caption, vbNullString, "C:", ByVal 1&
    Case 1
    ShellExecute Me.hWnd, "open", Option1(1).Caption, vbNullString, "C:", ByVal 1&
    Case 2
    ShellExecute Me.hWnd, "open", Option1(2).Caption, vbNullString, "C:", ByVal 1&
    Case 3
    ShellExecute Me.hWnd, "open", Option1(3).Caption, vbNullString, "C:", ByVal 1&
    Case 4
    ShellExecute Me.hWnd, "open", Option1(4).Caption, vbNullString, "C:", ByVal 1&
    End Select

    End Sub
    [/code]

  • : : : Quite simple really. Put a 5 button Option Button array and 1 Web Browser control on a Form and then just paste in this code.
    : : :
    : : : The URL's for the sites are stored in the Option Buttons' Caption Property and as soon as one of them is clicked, the Browser is directed to that URL.
    : : :
    : : : [code]
    : : : Private Sub Option1_Click(Index As Integer)
    : : : Select Case Index
    : : : Case 0
    : : : WebBrowser1.Navigate (Option1(0).Caption)
    : : : Case 1
    : : : WebBrowser1.Navigate (Option1(1).Caption)
    : : : Case 2
    : : : WebBrowser1.Navigate (Option1(2).Caption)
    : : : Case 3
    : : : WebBrowser1.Navigate (Option1(3).Caption)
    : : : Case 4
    : : : WebBrowser1.Navigate (Option1(4).Caption)
    : : : End Select
    : : : End Sub
    : : : [/code]
    : : :
    : : ok I tried this and it does go to the website in the browser control. What I wanted to do was make my app open IE or the default browser on the users computer so they have print, back, forward facilties etc.
    : :
    : : So User click on the option (or from the list on the menu) and it opens IE on the specifice page.
    : :
    : OK, in that case you'll need to make an API call.
    :
    : Paste this function into your project:
    : [code]
    : Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    : ByVal hWnd As Long, _
    : ByVal lpOperation As String, _
    : ByVal lpFile As String, _
    : ByVal lpParameters As String, _
    : ByVal lpDirectory As String, _
    : ByVal nShowCmd As Long) As Long
    : [/code]
    :
    : Then call it with:
    :
    : [code]
    : Private Sub Option1_Click(Index As Integer)
    : Select Case Index
    : Case 0
    : ShellExecute Me.hWnd, "open", Option1(0).Caption, vbNullString, "C:", ByVal 1&
    : Case 1
    : ShellExecute Me.hWnd, "open", Option1(1).Caption, vbNullString, "C:", ByVal 1&
    : Case 2
    : ShellExecute Me.hWnd, "open", Option1(2).Caption, vbNullString, "C:", ByVal 1&
    : Case 3
    : ShellExecute Me.hWnd, "open", Option1(3).Caption, vbNullString, "C:", ByVal 1&
    : Case 4
    : ShellExecute Me.hWnd, "open", Option1(4).Caption, vbNullString, "C:", ByVal 1&
    : End Select
    :
    : End Sub
    : [/code]
    :
    :
    Cheers Doofus boy ... thanks for that I will give it a spion on Monday at the office .....
  • : : : : Quite simple really. Put a 5 button Option Button array and 1 Web Browser control on a Form and then just paste in this code.
    : : : :
    : : : : The URL's for the sites are stored in the Option Buttons' Caption Property and as soon as one of them is clicked, the Browser is directed to that URL.
    : : : :
    : : : : [code]
    : : : : Private Sub Option1_Click(Index As Integer)
    : : : : Select Case Index
    : : : : Case 0
    : : : : WebBrowser1.Navigate (Option1(0).Caption)
    : : : : Case 1
    : : : : WebBrowser1.Navigate (Option1(1).Caption)
    : : : : Case 2
    : : : : WebBrowser1.Navigate (Option1(2).Caption)
    : : : : Case 3
    : : : : WebBrowser1.Navigate (Option1(3).Caption)
    : : : : Case 4
    : : : : WebBrowser1.Navigate (Option1(4).Caption)
    : : : : End Select
    : : : : End Sub
    : : : : [/code]
    : : : :
    : : : ok I tried this and it does go to the website in the browser control. What I wanted to do was make my app open IE or the default browser on the users computer so they have print, back, forward facilties etc.
    : : :
    : : : So User click on the option (or from the list on the menu) and it opens IE on the specifice page.
    : : :
    : : OK, in that case you'll need to make an API call.
    : :
    : : Paste this function into your project:
    : : [code]
    : : Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    : : ByVal hWnd As Long, _
    : : ByVal lpOperation As String, _
    : : ByVal lpFile As String, _
    : : ByVal lpParameters As String, _
    : : ByVal lpDirectory As String, _
    : : ByVal nShowCmd As Long) As Long
    : : [/code]
    : :
    : : Then call it with:
    : :
    : : [code]
    : : Private Sub Option1_Click(Index As Integer)
    : : Select Case Index
    : : Case 0
    : : ShellExecute Me.hWnd, "open", Option1(0).Caption, vbNullString, "C:", ByVal 1&
    : : Case 1
    : : ShellExecute Me.hWnd, "open", Option1(1).Caption, vbNullString, "C:", ByVal 1&
    : : Case 2
    : : ShellExecute Me.hWnd, "open", Option1(2).Caption, vbNullString, "C:", ByVal 1&
    : : Case 3
    : : ShellExecute Me.hWnd, "open", Option1(3).Caption, vbNullString, "C:", ByVal 1&
    : : Case 4
    : : ShellExecute Me.hWnd, "open", Option1(4).Caption, vbNullString, "C:", ByVal 1&
    : : End Select
    : :
    : : End Sub
    : : [/code]
    : :
    : :
    : Cheers Doofus boy ... thanks for that I will give it a spion on Monday at the office .....
    :
    thanks all ok
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories