代码1)用Shell函数直接调用explorer.exe来打开网页
代码2)使用Api函数ShellExecute实现打开网页
Private Sub Command1_Click() Dim strOpen strOpen = Shell("explorer.exe " & Text1, 1) End Sub Private Sub Form_Load() Text1 = "http://www.luyouqiwo.com" End Sub |
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 Dim strUrl As String Private Sub OpenUrl(tUrl As String) ShellExecute Me.hwnd, "Open", tUrl, 0, 0, 0 End Sub Private Sub Command1_Click() strUrl = Text1.Text OpenUrl (strUrl) End Sub Private Sub Form_Load() Text1 = "http://zhidao.baidu.com/" End Sub |
转载请注明:VB编程» VB使用默认浏览器打开网页,VB打开网页方法
标签: