|
| Author |
Message |
Dan
Joined: 04 Oct 2007 Posts: 4
|
Posted: Sat Apr 07, 2007 1:04 am Post subject: browser call |
|
|
What is the syntax to call the default browser with a URL string from VB? I
want the browser to open and take the focus to the page indicated by the
URL.
Thanks for your help.
Archived from group: microsoft>public>vb>syntax |
|
| Back to top |
|
 |
Larry Serflaten
Joined: 04 Oct 2007 Posts: 2644
|
Posted: Sat Apr 07, 2007 7:56 am Post subject: Re: browser call |
|
|
"Dan" wrote in message @TK2MSFTNGP06.phx.gbl...
> What is the syntax to call the default browser with a URL string from VB? I
> want the browser to open and take the focus to the page indicated by the
> URL.
>
> Thanks for your help.
>
http://www.google.com/search?hl=en&q=ShellExecute+URL |
|
| Back to top |
|
 |
Dan
Joined: 04 Oct 2007 Posts: 4
|
Posted: Mon Apr 09, 2007 11:23 am Post subject: Re: browser call |
|
|
I tried the code at http://www.devx.com/vb2themax/Tip/18339 (see below)
It compiles and runs but nothing happens. res comes back with a long number.
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
' Open the default browser on a given URL
' Returns True if successful, False otherwise
Private Sub btnGO_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnGO.Click
Dim res As Long
Dim URL As String
Dim openbrowser As Boolean
' it is mandatory that the URL is prefixed with http:// or https://
'If InStr(1, URL, "http", vbTextCompare) 1 Then
URL = "http://" & "ww.Microsoft.com"
'End If
res = ShellExecute(0&, "open", URL, vbNullString, vbNullString, _
vbNormalFocus)
OpenBrowser = (res > 32)
End Sub
End Class
"Larry Serflaten" wrote in message $XKPeHHA.4172@TK2MSFTNGP05.phx.gbl...
>
> "Dan" wrote in message
> @TK2MSFTNGP06.phx.gbl...
>> What is the syntax to call the default browser with a URL string from VB?
>> I
>> want the browser to open and take the focus to the page indicated by the
>> URL.
>>
>> Thanks for your help.
>>
>
> http://www.google.com/search?hl=en&q=ShellExecute+URL
>
> |
|
| Back to top |
|
 |
Larry Serflaten
Joined: 04 Oct 2007 Posts: 2644
|
Posted: Mon Apr 09, 2007 4:36 pm Post subject: Re: browser call |
|
|
"Dan" wrote
> I tried the code at http://www.devx.com/vb2themax/Tip/18339 (see below)
> It compiles and runs but nothing happens. res comes back with a long number.
You have to realize that until some later time in the future, the majority
of the VB examples you find on the web are going to be for classic
VB (versions 6 and prior), not for VB.Net. In fact this newsgroup
(as well as all other in the microsoft.public.vb.* tree) are for classic
VB. As you have found out, the two don't mix well....
For .Net questions, ask in a group dedicated to .Net discussions such
as: microsoft.public.dotnet.languages.vb
However, a quick look at the documentation shows you should be
able to get something going with System.Diagnostics.Process.Start
(Pass it the URL you want loaded).
HTH
LFS |
|
| Back to top |
|
 |
Ken Halter
Joined: 04 Oct 2007 Posts: 4150
|
Posted: Mon Apr 09, 2007 2:42 pm Post subject: Re: browser call |
|
|
"Larry Serflaten" wrote in message @TK2MSFTNGP03.phx.gbl...
>
> "Dan" wrote
>> I tried the code at http://www.devx.com/vb2themax/Tip/18339 (see below)
>> It compiles and runs but nothing happens. res comes back with a long
>> number.
>
> You have to realize that until some later time in the future, the majority
> of the VB examples you find on the web are going to be for classic
Especially since the article specifically states....
Language: VB4/32,VB5,VB6
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
|
|
| Back to top |
|
 |
|