Results 1 to 7 of 7

Thread: [RESOLVED] Firefox with VB6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Posts
    98

    Resolved [RESOLVED] Firefox with VB6

    Okay i have a text box and a command button. I want the user to type in an address in the text then click the command button to start up firefox and have it automatically load the address in the label. I got almost all of it to work
    Code:
    Website = Text1.Text
        Shell ("C:\Program Files\Mozilla Firefox\Firefox.exe Website")
    That will start up firefox but with Website as the address instead of the text.
    I tried many different ways but cant get it to work. Thanks

  2. #2
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Firefox with VB6

    Use ShellExecute. It will automatically open the default browser. If the user does not have FireFox installed or has it installed in a different directory than the one you've specified in your post, then your code will never work.

    vb Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    4.                         ByVal hwnd As Long, _
    5.                         ByVal lpOperation As String, _
    6.                         ByVal lpFile As String, _
    7.                         ByVal lpParameters As String, _
    8.                         ByVal lpDirectory As String, _
    9.                         ByVal nShowCmd As Long) _
    10.                         As Long
    11.  
    12. Private Sub Command1_Click()
    13.     Website = "http://www.vbforums.com"
    14.     ShellExecute Me.hwnd, "open", Website, vbNullString, vbNullString, vbNormal
    15. End Sub
    Last edited by Chris001; Jun 5th, 2007 at 07:55 PM.

  3. #3
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Firefox with VB6

    Would the following work?
    Code:
    Website = Text1.Text
        Shell ("C:\Program Files\Mozilla Firefox\Firefox.exe " & Website)
    Edit: I recommend what Chris said, but if you really want to just open firefox then the above will work.
    Last edited by Mxjerrett; Jun 5th, 2007 at 07:59 PM.

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Posts
    98

    Re: Firefox with VB6

    Quote Originally Posted by Chris001
    Use ShellExecute. It will automatically open the default browser. If the user does not have FireFox installed or has it installed in a different directory than the one you've specified in your post, then your code will never work.

    vb Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    4.                         ByVal hwnd As Long, _
    5.                         ByVal lpOperation As String, _
    6.                         ByVal lpFile As String, _
    7.                         ByVal lpParameters As String, _
    8.                         ByVal lpDirectory As String, _
    9.                         ByVal nShowCmd As Long) _
    10.                         As Long
    11.  
    12. Private Sub Command1_Click()
    13.     Website = "http://www.vbforums.com"
    14.     ShellExecute Me.hwnd, "open", Website, vbNullString, vbNullString, vbNormal
    15. End Sub
    Sorry if im wrong, but wont i, or the user have to put the site in through the source with that? i want to do it through a text box on the form.

    And no mx that didnt work.

  5. #5
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Firefox with VB6

    Then do it like this.

    To test the code below add a Command button to your form named "Command1" and a Textbox named "Text1". Type the url of a website into the Textbox and click the Command button.

    vb Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    4.                         ByVal hwnd As Long, _
    5.                         ByVal lpOperation As String, _
    6.                         ByVal lpFile As String, _
    7.                         ByVal lpParameters As String, _
    8.                         ByVal lpDirectory As String, _
    9.                         ByVal nShowCmd As Long) _
    10.                         As Long
    11.  
    12. Private Sub Command1_Click()
    13.     ShellExecute Me.hwnd, "open", Text1.Text, vbNullString, vbNullString, vbNormal
    14. End Sub

  6. #6
    Addicted Member cxj98's Avatar
    Join Date
    Feb 2007
    Posts
    170

    Re: Firefox with VB6

    ShellExecute to open a Hyperlink code really classical.
    Newbie to Visual Basic 6.0 Programming world!

  7. #7
    New Member
    Join Date
    Apr 2012
    Posts
    2

    Re: [RESOLVED] Firefox with VB6

    I really hate Explorer and have used Mozilla Firefox for years. This code for opening the default browser works and made my day. Thank you.

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