如何用VB编写简单的浏览器(要单击超链接时可以跳转的)
我用VB写了一个简单的浏览器,只能通过输入网址浏览网页,但是在打开的网页中的链接打不开。就例如在百度中搜出的选项都无法打开链接例如:当你单击这个链接时浏览器应该会转到这个...
我用VB写了一个简单的浏览器,只能通过输入网址浏览网页,但是在打开的网页中的链接打不开。就例如在百度中搜出的选项都无法打开链接 例如:当你单击这个链接时浏览器应该会转到这个页面(迅雷..........下载工具)
展开
3个回答
2013-08-08
展开全部
添加的控件有:1.Microsoft Internet Controls
2.Microsoft Windows Common Control
3. Microsoft Windows Common Dialpg软件用到的控件有:1.CommandButton控件 命名为打开网站.
2.WebBrowser控件 象地球
3.StatusBar控件和ProgressBar控件 是Common Control里面带的
4.ComboBox控件
5.CommonDialog控件
代码
Private Sub Combo1_Click()
WebBrowser1.Navigate Combo1.Text
End Sub Private Sub Form_Load()
Combo1.Text = ""
Combo1.Top = 0
Combo1.Left = 0
WebBrowser1.Top = Combo1.Top + Combo1.Height
WebBrowser1.Left = 0
Form_Resize
StatusBar1.Style = sbrSimple
ProgressBar1.ZOrder
End Sub
Private Sub Form_Resize()
On Error GoTo a
Combo1.Width = Form1.Width - 100
WebBrowser1.Width = Combo1.Width
WebBrowser1.Height = Form1.Height - Combo1.Height - 1000
ProgressBar1.Top = Me.Height - StatusBar1.Height - 330
ProgressBar1.Left = 0.25 * StatusBar1.Width
ProgressBar1.Width = 0.75 * Me.Width - 250
a:
End SubPrivate Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim I As Long
Dim existed As Boolean
If KeyCode = 13 Then
If Left(Combo1.Text, 7) <> "http://" Then
Combo1.Text = "http://" + Combo1.Text
End If
WebBrowser1.Navigate Combo1.Text
For I = 0 To Combo1.ListCount - 1
If Combo1.List(I) = Combo1.Text Then
existed = True
Exit For
Else
existed = False
End If
Next
If Not existed Then
Combo1.AddItem (Combo1.Text)
End If
End If
End Sub
2.Microsoft Windows Common Control
3. Microsoft Windows Common Dialpg软件用到的控件有:1.CommandButton控件 命名为打开网站.
2.WebBrowser控件 象地球
3.StatusBar控件和ProgressBar控件 是Common Control里面带的
4.ComboBox控件
5.CommonDialog控件
代码
Private Sub Combo1_Click()
WebBrowser1.Navigate Combo1.Text
End Sub Private Sub Form_Load()
Combo1.Text = ""
Combo1.Top = 0
Combo1.Left = 0
WebBrowser1.Top = Combo1.Top + Combo1.Height
WebBrowser1.Left = 0
Form_Resize
StatusBar1.Style = sbrSimple
ProgressBar1.ZOrder
End Sub
Private Sub Form_Resize()
On Error GoTo a
Combo1.Width = Form1.Width - 100
WebBrowser1.Width = Combo1.Width
WebBrowser1.Height = Form1.Height - Combo1.Height - 1000
ProgressBar1.Top = Me.Height - StatusBar1.Height - 330
ProgressBar1.Left = 0.25 * StatusBar1.Width
ProgressBar1.Width = 0.75 * Me.Width - 250
a:
End SubPrivate Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim I As Long
Dim existed As Boolean
If KeyCode = 13 Then
If Left(Combo1.Text, 7) <> "http://" Then
Combo1.Text = "http://" + Combo1.Text
End If
WebBrowser1.Navigate Combo1.Text
For I = 0 To Combo1.ListCount - 1
If Combo1.List(I) = Combo1.Text Then
existed = True
Exit For
Else
existed = False
End If
Next
If Not existed Then
Combo1.AddItem (Combo1.Text)
End If
End If
End Sub
2013-08-08
展开全部
Private Sub Form_Load()
Me.WebBrowser1.Navigate "baidu.com"
End SubPrivate Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim frm As Form1
Set frm = New Form1
frm.WebBrowser1.RegisterAsBrowser = True Set ppDisp = frm.WebBrowser1.Object
frm.Visible = True Unload Me
End Sub这个代码你试试吧
Me.WebBrowser1.Navigate "baidu.com"
End SubPrivate Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim frm As Form1
Set frm = New Form1
frm.WebBrowser1.RegisterAsBrowser = True Set ppDisp = frm.WebBrowser1.Object
frm.Visible = True Unload Me
End Sub这个代码你试试吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-08
展开全部
那要把该浏览器设置成默认浏览器才行啊!具休方法我就不知道了!建议你到编程中国论坛去看看吧!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |