Solved

how do i find default web browser?

Posted on 2002-06-05
9
156 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro which automatically send Excel spreadsheet to Outlook problem 2 61
VBA saving file message display 5 56
Spell Check in VB6 13 99
MsgBox 4 48
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

896 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now