Thursday, June 30, 2011

How to hyper link in a Label


Use this API and Function in Modual 

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
Public Sub HyperJump(ByVal URL As String)
Call ShellExecute(0&, _
vbNullString, URL, _
vbNullString, vbNullString, _
vbNormalFocus)
End Sub

Use in Form

Option Explicit

Private m_Active As Boolean
Private Sub Form_Load()
Label1.Caption = "http://www.vbcode.in"
Label1.Tag = Label1.Caption
End Sub

Private Sub Label1_Click()
With Label1
Call HyperJump(.Tag)
.Font.Underline = False
.ForeColor = vbBlack
End With

End Sub

No comments:

Post a Comment