在VB中我想实现这个

来源:百度知道 编辑:UC知道 时间:2024/09/27 15:26:45
在VB中我想实现这个:单击一个command按纽,然后打开http://www.baidu.com
请问这个按纽的代码该怎么写?

建一个COmmand1。
代码如下。
============
Private Sub Command1_Click()
Shell "explorer http://www.baidu.com", vbNormalFocus
End Sub

以下代码用api调用默认浏览器打开网页

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", "要打开的网址", vbNullString, vbNullString, &H0
End Sub

Private Sub Command1_Click()
Shell "start http://www.baidu.com"
End Sub

试试看咯 (好像不行)