当前位置:编程学习 > VB >>

VB制作一个网址的窗口

要求:

VB制作一个程序

打开一个这个程序,里面就有一个指向网址的,还能看到里面内容

比如打开程序看见这个程序里面显示:www.netvn98z.com的信息

补充:www.netvn98z.cn 前面是com错了
		
追问:请看这张图片 希望你能了解

答案:'添加一个WebBrowser控件,输入以下代码

'---------------------------------------------
'          VB制作精简的IE浏览器实例
'---------------------------------------------
'         百度群 飞度编程学社 1195277
'---------------------------------------------
'        作者:FLYDOO飞度 QQ:1046559384
'---------------------------------------------
Option Explicit
'变量声明
'strURL,字符型
Dim strURL As String

Private Sub Form_Load()
'设为True的作用是当网页出现脚本错误时不提示
  WebBrowser1.Silent = True
'在这里输入网页地址,在这里我随便改一个可用的地址便于测试
  WebBrowser1.Navigate "http://www.hao123.com"
'这是窗体名称的更新频率
  Timer1.Interval = 500
End Sub

'让所有链接都用这个浏览器打开
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate strURL
End Sub
Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
strURL = Text
End Sub

'当窗体大小改变时,使WebBrowser1控件大小填满整个窗口
Private Sub Form_Resize()
On Error Resume Next
WebBrowser1.Width = Me.Width - 100
WebBrowser1.Height = Me.Height - 450
End Sub

'结束
Private Sub Form_Unload(Cancel As Integer)
End
End Sub

'利用Timer来更新窗体标题
Private Sub Timer1_Timer()
Me.Caption = WebBrowser1.LocationName
Timer1.Enabled = True
End Sub

是不是这种呀?

 

打开浏览器,默认包含百度、163、新浪、搜狐、腾讯、CSDN.NET等网址,按方向键(→ ← ↑ ↓)选择相应网址,Ctrl+回车打开网页;      

我做的自动刷新网页程序!

 

Dim xlApp As Excel.Application '定义EXCEL类
Dim xlBook As Excel.Workbook
Private Sub Scriptlet1_onscriptletevent(ByVal name As String, ByVal eventData As Variant)

End Sub

Private Sub Command1_Click()
  If WebBrowser1.LocationURL = "http:///" Or WebBrowser1.LocationURL = "" Or WebBrowser1.Busy = True Then
  MsgBox "网页打开中.."
  Exit Sub
  End If
 
 
  Set xlApp = CreateObject("Excel.Application")
  xlApp.Visible = True
  Set xlBook = Workbooks.Add
  Set xlsheet = Worksheets.Add
  xlsheet.name = "hjw"
 
 
    Dim allCol
      Dim TagName1 As String
    Set allCol = WebBrowser1.Document.All
  allcount = allCol.Length
   
  Dim oo As Object
  'Dim tbl As HTMLTable
   
  Set idoc = WebBrowser1.Document
   
  Set oo = idoc.All.tags("tr")
   
     j = 1
     o = 1
      For i = 0 To allcount - 1

  
               TagName1 = allCol.Item(i).tagname
              
              ' Debug.Print TagName1
              Debug.Print j

                If TagName1 = "TR" Then
                j = j + 1
                o = 1
                'MsgBox "hang"
                End If
                If TagName1 = "TD" Then
         
              
               
               
                TagName1 = allCol.Item(i).innertext
                'Debug.Print j & "|" & i
                xlsheet.Cells(j, o) = LTrim(TagName1)
            o = o + 1
           
                   'List1.AddItem (LTrim(TagName1))
              End If
             
             
             
      Next
         
'WebBrowser1.Navigate Text1.Text
'SendKeys "{F5}", True
End Sub

Private Sub Command3_Click()
  If WebBrowser1.LocationURL = "http:///" Or WebBrowser1.LocationURL = "" Or WebBrowser1.Busy = True Then
  MsgBox "aa"
  Exit Sub
  End If
    Dim allCol
    '  Dim TagName1 As String
    Set allCol = WebBrowser1.Document.All
    Debug.Print allCol.Length
    Debug.Print LTrim(allCol.Item(800).innertext)
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
Debug.Print KeyAscii
End Sub

Private Sub Form_Load()
abc = "20090512"
 WebBrowser1.Navigate "http://128.128.10.33/crceer/form_stand_ops01_str.asp?sdate=20090513&form_id=61"
'Debug.Print WebBrowser1.Document
End Sub

Private Sub Label1_Click()

End Sub

Private Sub Timer1_Timer()

Debug.Print Second(Time)
If Second(Time) = "0" Then
 WebBrowser1.Navigate Text1.Text
 Me.Caption = "正在刷新网页...."
 Else
 Me.Caption = "剩余" & 60 - Second(Time) & "秒刷新网页!"
End If
End Sub
Private Sub Command2_Click()
Dim oWindow
Dim oNav
Set oWindow = WebBrowser1.Document.parentWindow
Set oNav = oWindow.navigator
Debug.Print oNav.userAgent
Debug.Print WebBrowser1.Document.All.Item(1).tagname
WebBrowser1.Document.All.Item(1).Value
WebBrowser1.Document.All.Item(1).Type


Set oWindow = Nothing
Set oNav = Nothing
End Sub

 

我编过一个,要的话加我,547312675

上一个:VB这个程序代码怎么写?
下一个:VB的代码问题。急!!!

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,