永发信息网

求vb高手详细解释语句

答案:2  悬赏:80  手机版
解决时间 2021-04-26 23:18

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 Sub
  
  Private Sub Combo1_Click()
  WebBrowser1.Navigate Combo1.Text  
  End Sub

  

  Private 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


  Private Sub WebBrowser1_DownloadBegin()
  StatusBar1.SimpleText = "载入中…"  
  End Sub

  

  Private Sub WebBrowser1_DownloadComplete()
  StatusBar1.SimpleText = "下载完成" 
  ProgressBar1.Value = 0
  End Sub

  
  Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long,ByVal ProgressMax As Long)
  If ProgressMax = 0 Then Exit Sub  
  ProgressBar1.Max = ProgressMax
  If Progress <> -1 And Progress <= ProgressMax Then
  ProgressBar1.Value = Progress
  End If
  End Sub
  
  Private Sub WebBrowser1_TitleChange(ByVal Text As String)
  Combo1.Text = WebBrowser1.LocationURL
  End Sub

  

  Private Sub Command1_Click()
  CommonDialog1.ShowOpen    
  WebBrowser1.Navigate CommonDialog1.FileName
  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 Sub
  '下拉列表框单击事件


  Private Sub Combo1_Click()


'加载下拉列表框中的指定的地址
  WebBrowser1.Navigate Combo1.Text  
  End Sub


  


  Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
  Dim I As Long
  Dim existed As Boolean


'判断是否按回车键
  If KeyCode = 13 Then


'判断是否已http://开头
  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


'地址加载开始事件
  Private Sub WebBrowser1_DownloadBegin()
  StatusBar1.SimpleText = "载入中…"  
  End Sub


  '地址加载完成事件


  Private Sub WebBrowser1_DownloadComplete()
  StatusBar1.SimpleText = "下载完成" 
  ProgressBar1.Value = 0
  End Sub


  '地址加载进度改变事件
  Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long,ByVal ProgressMax As Long)
  '判断进度条初始值是否为0


If ProgressMax = 0 Then Exit Sub


'设置进度条加载进度  
  ProgressBar1.Max = ProgressMax
  If Progress <> -1 And Progress <= ProgressMax Then
  ProgressBar1.Value = Progress
  End If
  End Sub
  
  Private Sub WebBrowser1_TitleChange(ByVal Text As String)


'设置首页
  Combo1.Text = WebBrowser1.LocationURL
  End Sub


  


  Private Sub Command1_Click()


'显示对话框
  CommonDialog1.ShowOpen


  '加载指定的链接地址  
  WebBrowser1.Navigate CommonDialog1.FileName
  End Sub


本人能力有限,不是专业搞VB回答有不妥之处望指正,谢谢

全部回答

这个写的是一个简易的浏览器

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
关闭IE时报错,IE报错,怎么解决?
用浏览、诠释、缩影、憧憬、裨益、潜移默化写
日语常用谚语大全,一些日语谚语的翻译
数学的一个题目
上月十五号还月经这个月一号在一起了会怀孕吗
谁会装VMware Workstation 7.0虚拟机啊,教我
平安易居南浦学区2号瑞锦店我想知道这个在什
谁有诛仙2电信1区相思木的推广员ID?
中国哪里最需要人才?
海尔笔记本上的fn是干什么用的?end home pgu
为什么我们家读卡器插进去无法使用
龙宿村地址在哪,我要去那里办事
视频斗斗地主怎么下载啊
如图,在正方形abcd中,点e为ad的中点,点g是
17岁,读了高一,我该找什么工作
推荐资讯
东莞自考考场具体都有哪些?
腰椎间盘突出饮食方面的注意事项?
为什么撒尿时感觉有点堵?
嗡。苏悉地迦哩缚哩。哆喃哆目哆曳(ye)。缚日
QQ三国最高级是多少级?发图片来看看
沈阳到大连需多长时间
DNF去遗训的门票那弄的
dnf超时空首饰我想升级两件 和耳环正好凑个3
这到底算什么!紧急求感情高手来解答!
本人是中专在校生! 有 车工中级 电焊初级 证
怀孕八个月了,能用手机上网吗?
济南工程学院怎么样?有谁知道?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?