VB中使用超链接?
单击一个Label,自动打开某个网址。如何实现?越简单越好
谢谢
问题点数:30、回复次数:4Top
1 楼yoki(小马哥--鬓微霜,又何妨)回复于 2003-12-01 15:57:33 得分 10
Public 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
Call ShellExecute(frmHrp.hwnd, "open", label1.caption ,vbNullString, vbNullString, &H5)Top
2 楼nik_Amis(...)回复于 2003-12-01 16:04:59 得分 10
楼上的方法有个毛病
会打开已经有的IE,非常不有好,这个不会,呵呵
Public Sub OpenSite(ByVal sURL As String)
Dim oIE As Object
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate sURL
oIE.Visible = True
Set oIE = Nothing
End Sub
Top
3 楼SoHo_Andy(冰)回复于 2003-12-01 16:05:36 得分 5
Public 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
举例说明,label2为控件数组
Private Sub Label2_Click(Index As Integer)
On Error GoTo ErrTrap
Select Case Label2(Index).Caption
Case "微软网站"
ShellExecute hwnd, "Open", "http://www.MicroSoft.com", 0, 0, 0
Case "程序员"
ShellExecute hwnd, "Open", "http://www.csdn.net", 0, 0, 0
End Select
On Error GoTo 0
Exit Sub
ErrTrap:
On Error GoTo 0
End Sub
Top
4 楼thl0352(红儿)回复于 2003-12-01 16:06:53 得分 5
同意楼上!
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 Sub Label1_Click()
Call ShellExecute(Form1.hwnd, "open", Label1.Caption, vbNullString, vbNullString, 1)
End Sub
Top




