Como criar Hyperlinks em um Label
A partir de um form, adicione 2 labels chamados Label1 e Label2.
Logo após adicione o código a seguir, clicando sobre os labels:
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 Label1_Click()
Dim ret&
ret = ShellExecute(Me.hwnd, “Open”, _
“http://www.webmundi.com”, _
“”, “”, 1)
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Label1.ForeColor = vbRed
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Label1.ForeColor = vbBlue
End Sub
Private Sub Label2_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Label2.ForeColor = vbRed
End Sub
Private Sub Label2_MouseUp(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Label2.ForeColor = vbBlue
End Sub
Private Sub Label2_Click()
Dim ret&
ret = ShellExecute(Me.hwnd, “Open”, _
“mailto:[email protected]?Subject=Criando Hyperlinks no label”, _
“”, “”, 1)
End Sub
Private Sub Form_Load()
With Label1
.AutoSize = True
.ForeColor = vbBlue
.Font.Italic = True
.Font.Underline = True
.Caption = “http://www.webmundi.com”
End With
With Label2
.AutoSize = True
.ForeColor = vbBlue
.Font.Italic = True
.Font.Underline = True
.Caption = “[email protected]”
End With
End Sub