Open a URL/Webpage in the Default Web Browser – VB.NET

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (17 votes, average: 4.41 out of 5)
 

The source code below will open the computers default Webbrowser with the specified link in Visual Basic.NET.

'
'Simply opens the default web browser and navigates to the specified url.
'This works with all versions of .NET including the latest 2005/08/2010 versions.

Dim webAddress As String = "http://www.vbcodesource.com"

Process.Start(webAddress)

37 thoughts on “Open a URL/Webpage in the Default Web Browser – VB.NET

  1. Kolklik

    This is by far the best way to open a website if you ask me, theres ofcourse also:
    System.Diagnostics.Process.Start(“http://www.helloworld.com”)

    Reply
  2. Jake

    Just what I needed :). The API call for opening a default web browser seems to only work on XP, :/ but this should work on other platforms as well :).

    Reply
  3. rahul

    hi ! this is a good example. thanks.
    Also I would like to know how i can open a URL using an activeX control in vb 2008?

    Reply
  4. DMK

    Thanks. Exactly what I needed. This way I can open links with ampersands in it. That did not work with my original code.

    Reply
  5. nuno

    just great… for so long that i’ve looking for something like this. And all the examples were so hard to understand! but now, just two lines! just great! thanks!!!

    eveyone in portugal is more happy now because of you! lol

    Reply
  6. Brian

    This is great. However, how do I close the webpage that I’ve opened? What is the command to do that task?

    Reply
  7. Jason Post author

    Hi, you can use API to do it. There is DestroyWindow API that should work.

    Public Declare Function DestroyWindow Lib “user32” Alias “DestroyWindow” (ByVal hwnd As IntPtr) As Integer

    You just need to get the handle of the window you want to close.

    Also there is the process class in the .net framework you can use. For Example:

    Process.GetCurrentProcess.Kill()

    One of those method should get you started. 🙂

    Jason

    Reply
  8. macieksoft

    i have sharp deceloop no visual studio, this is my error:

    Nie mo?na skonwertowaS wartotci typu „String” na „System.Diagnostics.ProcessStartInfo”. (BC30311) – C:UsersAdministratorDocumentsSharpDevelop ProjectsmcwdsremotepaMainForm.vb:28

    can anyone help me how i can convert string to system.diagnostic.processstart.info?

    Reply
  9. paolo

    hi can you help me out on this i want to send a url to the web browser using vb 2008 when i press a send button but i dont want to open the webrowser i just want to send a API command to process it without opening the browser? and how can i get the response from it like if respose is 0 then it’s sending message successfull

    Reply
  10. Darnel

    Any way to use this function without actually navigating to the opened page. I am trying to open a series of pages from a launching page.

    Thanks

    Reply
  11. Jason Post author

    Hi Darnel, I’m not exactly sure what you mean.

    Do you mean that you want each url in a list to open a separate browser window or tab? LMK with more details and I can try to help you. Thanks 🙂

    Jason

    Reply
  12. Praveen

    I am using a forms.webbrowser control on my VB.net application to whichI am passing all the values. I wan tot be able to launch the browser in my local system with the URL i provided. but still I wan to use only forms.webbrowser instead of controls.webbrowser.. any thoughts?

    Reply

Leave a Reply

Your email address will not be published.