Solved

how do i find default web browser?

Posted on 2002-06-05
9
159 Views
Last Modified: 2010-05-02
i want to make a vb program so that when i click a button, it opens up the default web browser and goes to the URL of my site.  is this possible with vb?
0
Comment
Question by:BobDole
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 1

Accepted Solution

by:
Toad224 earned 200 total points
ID: 7057023
You don't need to find out what the default browser is if you just want to open your site.  You should use the WinAPI ShellExecute(), and that will open the default browser automatically.

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


Private Sub Command1_Click()
ShellExecute 0, vbNullString, "http://experts-exchange.com", vbNullString, vbNullString, 1
End Sub

I hope that helps.  Good luck!
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7057040
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
Private Const SW_SHOWNORMAL = 1

Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", "http://www.google.com", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7057042
damn, too slow ;)
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:BobDole
ID: 7057068
neither of those work

i get some error   only comments may appear after end sub, end function, or end property

does anyone have code that works for vb6?
0
 
LVL 1

Expert Comment

by:Toad224
ID: 7057072
You need to put the

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

part at the top of the code in the form, or put

Public 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

at the top of your module.



Good luck!
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7057076
this is vb:

put this at the top of your form code:
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
Private Const SW_SHOWNORMAL = 1


then put this:
Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", "http://www.google.com", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7057079
damn, too slow again!
0
 
LVL 1

Expert Comment

by:Toad224
ID: 7057101
lol
0
 

Author Comment

by:BobDole
ID: 7057112
oh ****   that works   sweet!

thx guys
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
A macro to Count the number of rows across all worksheets 3 151
using web browser with BING 40 136
Can we place a tooltip on the actual vb6 form 5 53
Help me. 3 71
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question