Solved

Hyperlink to a website

Posted on 2003-10-21
9
184 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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
 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

770 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