[RESOLVED] How to call a web browser?
Hi, I writing a program and one of the features is calling a web browser. I need to execute a web browser and load with the address that i have specified in my code. How can i do that? Is that necessary to use Web Browser Control in the VB? I didn't use it before so kinda new to this control. Any advise?
Re: How to call a web browser?
Public Function OpenBrowser(ByVal URL As String) As Boolean
Dim res As Long
' it is mandatory that the URL is prefixed with http:// or https://
If InStr(1, URL, "http", vbTextCompare) <> 1 Then
URL = "http://" & URL
End If
res = ShellExecute(0&, "open", URL, vbNullString, vbNullString, _
vbNormalFocus)
OpenBrowser = (res > 32)
End Function
Re: How to call a web browser?
Hello @yosef_mreh! Next time you post a code, please place your code inside the code tags, to let the forum engine formating it, to a suitable format. You can do it by simply clicking on the (Code) button up the edit box's toolbar, there you typing.
There is also an api call is missing here, he/she cant use your code, without it.
http://allapi.mentalis.org/apilist/ShellExecute.shtml
Re: How to call a web browser?
or using the consol shell:
vb Code:
Shell "explorer.exe http://www.gegalo.com", vbNormalFocus
Re: How to call a web browser?
this might help
goto Add-in > API Viewer and referrence to ShellExecute api.
Code:
Public Function OpenWebpage(strWebpage As String)
ShellExecute 0&, vbNullString, strWebpage, vbNullString, _
vbNullString, vbNormalFocus
End Function
Code:
Private Sub Command1_Click()
OpenWebpage "http://www.vbforums.com/showthread.php?t=551194"
End Sub
Re: How to call a web browser?
yeah...it's work. Thanks a lot to everyone.
Re: [RESOLVED] How to call a web browser?
also u can use firefox
Code:
Shell "C:\Program Files\Mozilla Firefox\firefox.exe www.google.com"