Solved

Hyperlink to a website

Posted on 2003-10-21
9
183 Views
Last Modified: 2012-05-04
I have a VB application.  I have a help/about button that when pressed fires off a form.  The form contains information about the application: version, date, regsitration etc.  I would like to add a commandbutton to the "about" form that would, when pressed, link to a web page (hypelink).  

How do I create the hyperlink using a commandButton?
0
Comment
Question by:bgdw
9 Comments
 
LVL 1

Expert Comment

by:blkbam
ID: 9595343
Can't go wrong when someone has done it for you.

http://www.developerfusion.com/show/340/3/

Just be sure to give the author proper credit  :)
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 9595348
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_SHOW = 1

'' then in onclick event of button

Private Sub Command1_Click()
  Dim href as String
  href = "http://www.google.com"
  hBrowse = ShellExecute(Me.hwnd, "open", href, vbnullstring, vbnullstring, SW_SHOW)
End Sub



0
 
LVL 1

Expert Comment

by:blkbam
ID: 9595360
But if you really want code:

Add a reference to "Microsoft Internet Controls"
then use the following code:

Public Sub LaunchSite(url As String)
    Dim ie As InternetExplorer
     Set ie = New InternetExplorer
    'open file in internet explorer
    With ie
        .Navigate2 url
        .Height = 800
        .Width = 700
        .Left = 25
        .Top = 25
        .Visible = True
    End With
    Set ie = Nothing
End Sub

url can be either a path and/or file name or an actual URL.
0
 
LVL 2

Expert Comment

by:BUCHAS
ID: 9595376
This article shows exactly what you want without use of any 3rd-party control, with the same look as an IE link... see which suits you better.

http://www.mvps.org/vbnet/code/intrinsic/sehyperlink.htm
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 5

Expert Comment

by:fantasy1001
ID: 9595469
'Put this in a module:
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

' And here is your code
Private Sub Command1_Click()
     Dim retval As Long
     retval = ShellExecute(hwnd, "Open", "http://www.google.com", "", App.Path, 1)
End Sub


Thanks & Cheers
0
 

Expert Comment

by:flynn2000
ID: 9602469
private sub command1_click()
    Shell ("explorer http://www.google.com")
End Sub
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 250 total points
ID: 9602715
my suggestion (which is pretty much the same as fantasy's) only posted first ;) is the solution i think you want to go with... it will open up the DEFAULT browser. Not dependant on IE.
0
 
LVL 1

Expert Comment

by:fsaims
ID: 9612703
Suggestion of bobbit31 will work out perfectly
0
 

Author Comment

by:bgdw
ID: 9645484
Thanks for the help.
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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

912 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

22 Experts available now in Live!

Get 1:1 Help Now