Solved

create a hyperlink in vb6

Posted on 2004-08-31
5
1,129 Views
Last Modified: 2012-06-27
how can i create a hyperlink in vb6?

such as a button that will send an email to a set email address

thanks
0
Comment
Question by:rinkydink
5 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11949171
Option Explicit

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, vbNullString, "mailto:someOne@someIsp.net", _
        vbNullString, "C:\", SW_SHOWNORMAL
End Sub
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 11949660
You can use ShellExecute to create a hyperlink, for eg. write the URL on a label and underline it to depict a hyperlink on the Click event of the Label use

Call ShellExecute( Me.hwnd, vbNullString, "http://google.com", vbNullString, "C:\", 1)

You need to declare the ShellExecute API at module/form level

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

if you give mailto:xxx in the URL it will open the default mail client for composing the mail and the user will have to send it.

0
 
LVL 2

Accepted Solution

by:
craigewens earned 100 total points
ID: 11950170
Create a label, and name it lblURL, and set its caption property to the internet address you want. If the URL is an email address, then un-comment one of the 'Call ShellExecute' lines, and comment out the line below that.

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 lblURL_DragDrop(Source As Control, X As Single, Y As Single)
    If Source Is lblUrl Then
        With lblUrl
            .Font.Underline = False
            .ForeColor = vbBlack
            ' Call ShellExecute(0&, vbNullString, "Mailto:" & .Caption, vbNullString, vbNullString, vbNormalFocus)
            Call ShellExecute(0&, vbNullString, .Caption, vbNullString, vbNullString, vbNormalFocus)
        End With
    End If
End Sub

Private Sub lblURL_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    If State = vbLeave Then
        With lblUrl
            .Drag vbEndDrag
            .Font.Underline = False
            .ForeColor = vbBlack
        End With
    End If
End Sub

Private Sub lblURL_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    With lblUrl
        .ForeColor = vbBlue
        .Font.Underline = True
        .Drag vbBeginDrag
    End With
End Sub
0
 
LVL 76

Expert Comment

by:David Lee
ID: 11950637
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

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

707 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

13 Experts available now in Live!

Get 1:1 Help Now