View Full Version : Opening website with Visual Basic
_Xternal34
12-12-2006, 05:13 PM
Ok.. I'm still new to VB, so yeah. I need the code for opening a URL without shelling to a specific browser. Like, the most I have right now... is shelling to FireFox, and opening URL from there.
I want it to open default browser, and that yeah. :] plz help.
oracleguy
12-12-2006, 07:32 PM
You should be able to do so by using the ShellExecute API call.
This goes in the form declerations:
'declare constants:
Private Const SW_SHOWNORMAL = 1
'declare API:
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
And then to open the URL:
ShellExecute(Me.hwnd, vbNullString, "http://www.codingforums.com", vbNullString, _
"", SW_SHOWNORMAL)
_Xternal34
12-12-2006, 09:05 PM
With the opening URL code, :\ I get a syntax error. :(
oracleguy
12-12-2006, 09:48 PM
Lose the parentheses around the function parameters.
ShellExecute Me.hwnd, vbNullString, "http://www.codingforums.com", vbNullString, _
"", SW_SHOWNORMAL
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.