Private Sub Form_Load()
Set lblURL = Controls.Add("VB.Label", "lblURL", Me)
With lblURL
.Caption = "http://www.163.com"
.AutoSize = True
.Top = 50 * 15
.Left = 100 * 15
.Visible = True
End With
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblURL.ForeColor = vbBlack
lblURL.FontUnderline = False
lblURL.MousePointer = vbDefault
End Sub
Private Sub lblURL_Click()
Dim frm As New Form1
frm.Show
End Sub
Private Sub lblURL_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblURL.ForeColor = vbBlue
lblURL.FontUnderline = True
lblURL.MousePointer = vbUpArrow
End Sub
Private Sub Form_Load()
Set lblURL = Controls.Add("VB.Label", "lblURL", Me)
With lblURL
.Caption = "http://www.163.com"
.AutoSize = True
.Top = 50 * 15
.Left = 100 * 15
.Visible = True
End With
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblURL.ForeColor = vbBlack
lblURL.FontUnderline = False
lblURL.MousePointer = vbDefault
End Sub
Private Sub lblURL_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblURL.ForeColor = vbBlue
lblURL.FontUnderline = True
lblURL.MousePointer = vbUpArrow
End Sub
使用API函数ShellExcute
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
在Label控件的click事件上加入代码:
Private Sub lblURL_Click()
Dim HyperJump
HyperJump = ShellExecute(0&, vbNullString, WEB, vbNullString,
vbNullString, vbNormalFocus)
其中WEB为你定义的超连接地址,例如:
Private Const WEB = "http://i.am/hellprisoner"
如果需要调入email,就要在email地址前加入mailto: 例如
Private Const WEB = "mailto:prisoner@990.net"
如果再在Label的属性中设置MousePointer = 99 'Custom 并把MouseIcon
设置为一只手的图标,当鼠标移动到标签上时,指针就变成手的形状,这就更
象超连接了。
- Prisoner
回答2:
可以先建立两个label控件label1和label2.设他们的caption分别为"我的mail"
和"我的主页"(或是其他你想要显示的内容).然后加入如下代码:
Private Sub Label1_Click()
Set ie = New InternetExplorer
ie.Visible = False
ie.Navigate "mailto:weiv@163.net"
End Sub
Private Sub Label2_Click()
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "http://playworld.126.com"
End Sub