|
-
Jun 5th, 2007, 07:31 PM
#1
Thread Starter
Lively Member
[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
-
Jun 5th, 2007, 07:52 PM
#2
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:
Option Explicit
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
Private Sub Command1_Click()
Website = "http://www.vbforums.com"
ShellExecute Me.hwnd, "open", Website, vbNullString, vbNullString, vbNormal
End Sub
Last edited by Chris001; Jun 5th, 2007 at 07:55 PM.
-
Jun 5th, 2007, 07:56 PM
#3
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.
-
Jun 5th, 2007, 08:00 PM
#4
Thread Starter
Lively Member
Re: Firefox with VB6
 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:
Option Explicit
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
Private Sub Command1_Click()
Website = "http://www.vbforums.com"
ShellExecute Me.hwnd, "open", Website, vbNullString, vbNullString, vbNormal
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.
-
Jun 5th, 2007, 08:06 PM
#5
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:
Option Explicit
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
Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", Text1.Text, vbNullString, vbNullString, vbNormal
End Sub
-
Jun 5th, 2007, 08:11 PM
#6
Addicted Member
Re: Firefox with VB6
ShellExecute to open a Hyperlink code really classical.
Newbie to Visual Basic 6.0 Programming world!
-
Apr 6th, 2012, 02:31 AM
#7
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|