msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

browser call

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
Dan



Joined: 04 Oct 2007
Posts: 4

PostPosted: Sat Apr 07, 2007 1:04 am    Post subject: browser call Reply with quote

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
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Sat Apr 07, 2007 7:56 am    Post subject: Re: browser call Reply with quote

"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
View user's profile Send private message
Dan



Joined: 04 Oct 2007
Posts: 4

PostPosted: Mon Apr 09, 2007 11:23 am    Post subject: Re: browser call Reply with quote

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
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Mon Apr 09, 2007 4:36 pm    Post subject: Re: browser call Reply with quote

"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
View user's profile Send private message
Ken Halter



Joined: 04 Oct 2007
Posts: 4150

PostPosted: Mon Apr 09, 2007 2:42 pm    Post subject: Re: browser call Reply with quote

"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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group