How to open a URL in the default browser from your VB-app?


Declare the following in a .bas module or similar:

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As _
String, ByVal lpParameters As String, ByVallpDirectory As String, _
ByVal nShowCmd As Long) As Long
Public Const SW_SHOWNORMAL = 1

Then use the following code to make the shell:

Dim a As Long
a = ShellExecute(Me.hwnd, "open", "www.oden.se/~daniel/", "", "C:\", SW_SHOWNORMAL)

Replace the URL in this example with the one you want.


Mail to Daniel Wiman <daniel@wimania.com>
Online since June 1996, updated 980911
<- The VB home
<- Daniels homepage