鼠标点击事件,点击 Label 链接 www.163.com 。代码如下:
Private Sub Label1_Click()
Shell "c:\Program Files\Internet Explorer\IEXPLORE.EXE www.163.com", 1
End Sub要求:当系统装在D:盘下的时候,点击Label还能打开网页,或者说当系统安装在随便什么盘上都还,依然可以打开网页。不知道如下代码是否可行:Private Sub Command2_Click()
On Error Resume Next
Dim o As Object
Set o = CreateObject("wscript.shell")
o.run ("IEXPLORE.EXE www.163.com")
Set o = Nothing
End Sub

解决方案 »

  1.   

    应该是这样:
    Private Sub Label1_Click() 
    On Error Resume Next 
    Dim o As Object 
    Set o = CreateObject("wscript.shell") 
    o.run ("IEXPLORE.EXE www.163.com") 
    Set o = Nothing 
    End Sub
    当系统安装在D盘的时候,点击Label还能打开网页不?
      

  2.   

    怎么样鼠标停留在Label1的时候文本变色呢?谢谢了!
      

  3.   

    用API好点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 LongPrivate Sub Form_Load()
       Label1.ForeColor = vbBlue
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
       If Label1.ForeColor <> vbBlue Then
          Label1.ForeColor = vbBlue
       End If
    End SubPrivate Sub Label1_Click()
       ShellExecute 0, "open", "http://www.163.com", "", App.Path, 5
    End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
       If Label1.ForeColor <> vbRed Then
          Label1.ForeColor = vbRed
       End If
    End Sub