求:VB ShellExecute时出错
代码:
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
ShellExecute Me.hWnd, "open", "http://www.baidu.com/", "", "", 1
错误提示:子程序或函数未定义。
请问是什么原因?
[解决办法]
我测试了,没有任何问题。可以直接打开百度网页。
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 Command1_Click()
ShellExecute Me.hWnd, "open", "http://www.baidu.com/", "", "", 1
End Sub
应该是其他问题。为了确认,你可以新建一个工程,贴进上述代码试试。
估计你现在的机器缺少某个你现在这个工程引用的库。在“工程”-“引用”对话框中看一下,是否有报错的引用库。