Open URL

How can I make it so that a person enters an URL in a text box and clocks "go" and it will open the default broswer and go to that url?
kinger2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
"HOWTO: Programmatically Launch the Default Internet Browser"

http://support.microsoft.com/support/kb/articles/Q174/1/56.ASP
0
kinger2000Author Commented:
That did not work and plus I want ir so that the user enters the URL not a default one and then when they entered the url it opens the broswer- etc... I put

 Private Const SW_SHOW = 5       ' Displays Window in its current size
                                             ' and position
             Private Const SW_SHOWNORMAL = 1 ' Restores Window if Minimized or
                                             ' Maximized

             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 Declare Function FindExecutable Lib "shell32.dll" Alias _
                "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As _
                String, ByVal lpResult As String) As Long

is the module and this
Private Sub Command1_Click()
             Dim FileName, Dummy As String
             Dim BrowserExec As String * 255
             Dim RetVal As Long
             Dim FileNumber As Integer

             ' First, create a known, temporary HTML file
             BrowserExec = Space(255)
             FileName = "C:\temphtm.HTM"
             FileNumber = FreeFile                    ' Get unused file number
             Open FileName For Output As #FileNumber  ' Create temp HTML file
                 Write #FileNumber, "<HTML> <\HTML>"  ' Output text
             Close #FileNumber                        ' Close file
             ' Then find the application associated with it
             RetVal = FindExecutable(FileName, Dummy, BrowserExec)
             BrowserExec = Trim(BrowserExec)
             ' If an application is found, launch it!
             If RetVal <= 32 Or IsEmpty(BrowserExec) Then ' Error
                 MsgBox "Could not find associated Browser", vbExclamation, _
                   "Browser Not Found"
             Else
                 RetVal = ShellExecute(Me.hwnd, "open", BrowserExec, _
                   "www.microsoft.com", Dummy, SW_SHOWNORMAL)
                 If RetVal <= 32 Then        ' Error
                     MsgBox "Web Page not Opened", vbExclamation, "URL Failed"
                 End If
             End If
             Kill FileName                   ' delete temp HTML file
             End Sub
in a command button
when i ran it, it says erorr in the " find findexecutable" part of it.
0
Erick37Commented:
Try this:

Private Const SW_SHOW = 5
Private Const SW_SHOWNORMAL = 1
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 Declare Function FindExecutable Lib "shell32.dll" Alias _
    "FindExecutableA" (ByVal lpFile As String, _
    ByVal lpDirectory As String, ByVal lpResult As String) As Long
     
Private Sub Command1_Click()
    Dim FileName As String
    Dim BrowserExec As String * 255
    Dim RetVal As Long
    Dim FileNumber As Integer
    ' First, create a known, temporary HTML file
    BrowserExec = Space(255)
    FileName = App.Path & "temphtm.html"
    FileNumber = FreeFile ' Get unused file number
    Open FileName For Output As #FileNumber  ' Create temp HTML file
    Write #FileNumber, "<HTML> <\HTML>" ' Output text
    Close #FileNumber ' Close file
    ' Then find the application associated with it
    RetVal = FindExecutable(FileName, vbNullString, BrowserExec)
    BrowserExec = Trim(BrowserExec)
    ' If an application is found, launch it!
    If RetVal <= 32 Or IsEmpty(BrowserExec) Then ' Error
        MsgBox "Could not find associated Browser", _
            vbExclamation, "Browser Not Found"
    Else
        RetVal = ShellExecute(Me.hwnd, "open", BrowserExec, _
            Text1.Text, vbNullString, SW_SHOWNORMAL)
        If RetVal <= 32 Then ' Error
            MsgBox "Web Page not Opened", vbExclamation, "URL Failed"
        End If
    End If
    Kill FileName ' delete temp HTML file
End Sub

Private Sub Form_Load()
    Text1.Text = "http://oldlook.experts-exchange.com/"
End Sub
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

kamallCommented:
Well, try this 'magical' one-line code;

Private Sub Command1_Click()
    Shell ("start http://" & Text1.Text)
End Sub

Thats all!!! :-)
Note: In the text box, just enter the url name without the 'http://'. Example: www.yahoo.com

Regards.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kamallCommented:
BTW, I think this 'magical' one-line code worths more than 10 points. Isn't it? :-)
0
kamallCommented:
kinger2000,
It was very unfair of you to leave this question ungraded, with only 10 points assigned!!!!!
0
kinger2000Author Commented:
so answer it
0
kamallCommented:
?????????????????????
Wasn't it answered by me?, and you left it without even spendign half a minute to just grade the answer?
0
gpbaldazziCommented:
I've tried to use this code:

Shell "start http://www.microsoft.com"

but it doesn't works: it fails with error 53: file not found.

I use WinNT, VB 6.0 SP3 and my default browser is IE5.0.

What's wrong?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.