Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations danielledunham on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

launch a web browser from windows application form

Status
Not open for further replies.

vinteron

Programmer
Joined
Dec 19, 2005
Messages
4
Location
US
I'm a new programmer and am trying to launch a web browser from a windows application form. When running the code below I get an error message file not found message. Does anyone know why and how to fix this?
___________________________________________________
Private Sub OpenURL(ByVal URL As String)

System.Diagnostics.Process.Start("cmd/c ""start
End Sub

Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
Dim url As String

Call OpenURL(URL)

_________________________________________________________

An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll

Additional information: The system cannot find the file specified
 
A couple of points:

Your format for Process.Start with a Command Tail is wrong see below.

You do not use the URL parameter in the Sub OpenURL.


This is your code modified to work.
Code:
  Private Sub OpenURL(ByVal URL As String)

    System.Diagnostics.Process.Start([b]"cmd", "/c start [URL unfurl="true"]http://www.google.com"""[/URL][/b])

  End Sub


  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim URL As String
    OpenURL(url)

  End Sub

This version uses the URL parameter - the button click could perhaps pick up the URL from an InputBox or other UI element.
Code:
  Private Sub OpenURL(ByVal URL As String)

    System.Diagnostics.Process.Start("cmd", "/c start " + URL)

  End Sub


  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim URL As String = "[URL unfurl="true"]http://www.google.com"[/URL]
    OpenURL(URL)

  End Sub

Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top