Click here to Skip to main content
Click here to Skip to main content
Alternative Tip
Go to top

Opening the Internet Browser Programmatically

, 18 Aug 2011
Rate this:
Please Sign up or sign in to vote.
Given below is code for opening the Internet browser programmatically in VB 6 and VB.NET.VB 6Private Declare Function ShellExecute Lib "shell32.dll" Alias _ "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As...

Given below is code for opening the Internet browser programmatically in VB 6 and VB.NET.

VB 6
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 btnWebsite_Click()
    ShellExecute Me.hwnd, "open", "http://www.codeproject.com/", _
                 vbNullString, vbNullString, vbNormal
End Sub
VB.NET

This will open the URL in the default browser:

System.Diagnostics.Process.Start("http://www.codeproject.com")

This will open the website in Internet Explorer. Here you have the option to change the browser in your code.

System.Diagnostics.Process.Start("iexplore.exe", "http://www.codeproject.com")

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

thatraja
Web Developer
India India
Programmer | Dude | ||||||
 
About him & his blog? check out here. Currently he's updating the site, he'll return soon there with more things*.
 
In Codeproject, he posted a blogpost & more than couple of Tip/Tricks, hope he'll write more soon.
 
Favorite techs are MVC, WCF, Mobile, HTML5, CSS3, jQuery, etc.,
 
His hobbies are watching movies, CP, being alone, etc., But now he's working on something*.
 
* - SCAMP???
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 18 Aug 2011
Article Copyright 2011 by thatraja
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid