Solved

Hyperlink to a website

Posted on 2003-10-21
9
181 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
Comment Utility
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
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_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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 5

Expert Comment

by:fantasy1001
Comment Utility
'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
Comment Utility
private sub command1_click()
    Shell ("explorer http://www.google.com")
End Sub
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 250 total points
Comment Utility
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
Comment Utility
Suggestion of bobbit31 will work out perfectly
0
 

Author Comment

by:bgdw
Comment Utility
Thanks for the help.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

8 Experts available now in Live!

Get 1:1 Help Now