Solved

how do i find default web browser?

Posted on 2002-06-05
9
155 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
Comment Utility
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
Comment Utility
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
Comment Utility
damn, too slow ;)
0
 

Author Comment

by:BobDole
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:Toad224
Comment Utility
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
Comment Utility
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
Comment Utility
damn, too slow again!
0
 
LVL 1

Expert Comment

by:Toad224
Comment Utility
lol
0
 

Author Comment

by:BobDole
Comment Utility
oh ****   that works   sweet!

thx guys
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

15 Experts available now in Live!

Get 1:1 Help Now