⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 vb编程实例2
💻 FRM
字号:
VERSION 5.00
Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "shdocvw.dll"
Begin VB.Form Form1 
   Caption         =   "获取Web网页中所有的超级链接"
   ClientHeight    =   6960
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9990
   LinkTopic       =   "Form1"
   ScaleHeight     =   6960
   ScaleWidth      =   9990
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   495
      Left            =   7665
      TabIndex        =   4
      Top             =   1215
      Width           =   2070
   End
   Begin VB.TextBox Text1 
      Height          =   330
      Left            =   285
      TabIndex        =   3
      Text            =   "E:\市委党校\index.htm"
      Top             =   60
      Width           =   7095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "获取超级链接"
      Height          =   495
      Left            =   7665
      TabIndex        =   2
      Top             =   450
      Width           =   2070
   End
   Begin VB.ListBox List1 
      Height          =   1320
      Left            =   285
      TabIndex        =   1
      Top             =   450
      Width           =   7095
   End
   Begin SHDocVwCtl.WebBrowser WebBrowser1 
      Height          =   4650
      Left            =   285
      TabIndex        =   0
      Top             =   2160
      Width           =   9495
      ExtentX         =   16748
      ExtentY         =   8202
      ViewMode        =   1
      Offline         =   0
      Silent          =   0
      RegisterAsBrowser=   0
      RegisterAsDropTarget=   1
      AutoArrange     =   -1  'True
      NoClientEdge    =   0   'False
      AlignLeft       =   0   'False
      NoWebView       =   0   'False
      HideFileNames   =   0   'False
      SingleClick     =   0   'False
      SingleSelection =   0   'False
      NoFolders       =   0   'False
      Transparent     =   0   'False
      ViewID          =   "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
      Location        =   "http:///"
   End
   Begin VB.Label Label1 
      Height          =   255
      Left            =   300
      TabIndex        =   5
      Top             =   1830
      Width           =   7065
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Any) As Long
Const LB_SETHORIZONTALEXTENT = &H194

Private Sub Form_Load()
  Text1.Text = App.Path & "\mr\index.htm"   '设置默认网址
  WebBrowser1.Navigate (Text1.Text)
End Sub
Private Sub Command1_Click()
  Dim TagName, str As String
  Dim count, i, k As Integer
  Dim cols
  List1.Clear
  Set cols = WebBrowser1.Document.All
  count = cols.length
  k = 0
  While i < count
    TagName = cols.Item(i).TagName
    If TagName = "A" Or TagName = "IMG" Then  '查找超链接和img图形
        str = k & "  " & TagName & "... " & cols.Item(i).href
        List1.AddItem (str)       '增加超链接
        SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, Me.TextWidth(str), ByVal 0&  '为list加水平滚动条
        k = k + 1
    End If
    i = i + 1
  Wend
  Label1.Caption = "本网页共有超级连接:" & k & "  个"
End Sub

Private Sub Command2_Click()
  End
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -