Click here to Skip to main content
12,816,032 members (38,291 online)
Click here to Skip to main content
Add your own
alternative version

Stats

5.4K views
3 bookmarked
Posted 18 Aug 2011

Opening the Internet Browser Programmatically

, 18 Aug 2011 CPOL
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
Retired from Q/A section & Technical forums since 2014

More coming soon....

You may also be interested in...

Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 18 Aug 2011
Article Copyright 2011 by thatraja
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid