Results 1 to 7 of 7

Thread: [RESOLVED] How to call a web browser?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    282

    Resolved [RESOLVED] How to call a web browser?

    Hi, I writing a program and one of the features is calling a web browser. I need to execute a web browser and load with the address that i have specified in my code. How can i do that? Is that necessary to use Web Browser Control in the VB? I didn't use it before so kinda new to this control. Any advise?
    I'm still on the path of learning....

  2. #2
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    Re: How to call a web browser?

    Public Function OpenBrowser(ByVal URL As String) As Boolean
    Dim res As Long

    ' it is mandatory that the URL is prefixed with http:// or https://
    If InStr(1, URL, "http", vbTextCompare) <> 1 Then
    URL = "http://" & URL
    End If

    res = ShellExecute(0&, "open", URL, vbNullString, vbNullString, _
    vbNormalFocus)
    OpenBrowser = (res > 32)
    End Function
    IT CTO & System Administrator.

  3. #3
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: How to call a web browser?

    Hello @yosef_mreh! Next time you post a code, please place your code inside the code tags, to let the forum engine formating it, to a suitable format. You can do it by simply clicking on the (Code) button up the edit box's toolbar, there you typing.

    There is also an api call is missing here, he/she cant use your code, without it.
    http://allapi.mentalis.org/apilist/ShellExecute.shtml

  4. #4
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    Re: How to call a web browser?

    or using the consol shell:

    vb Code:
    1. Shell "explorer.exe http://www.gegalo.com", vbNormalFocus
    IT CTO & System Administrator.

  5. #5
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: How to call a web browser?

    this might help

    goto Add-in > API Viewer and referrence to ShellExecute api.

    Code:
    Public Function OpenWebpage(strWebpage As String)
    ShellExecute 0&, vbNullString, strWebpage, vbNullString, _
          vbNullString, vbNormalFocus
    End Function
    Code:
    Private Sub Command1_Click()
    OpenWebpage "http://www.vbforums.com/showthread.php?t=551194"
    End Sub

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    282

    Re: How to call a web browser?

    yeah...it's work. Thanks a lot to everyone.
    I'm still on the path of learning....

  7. #7
    Lively Member
    Join Date
    Nov 2008
    Posts
    101

    Re: [RESOLVED] How to call a web browser?

    also u can use firefox
    Code:
    Shell "C:\Program Files\Mozilla Firefox\firefox.exe www.google.com"

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