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

📄 frmdownload.frm

📁 如何实现文件下载
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmdownload 
   Caption         =   "Download Web Pages"
   ClientHeight    =   5715
   ClientLeft      =   2790
   ClientTop       =   2190
   ClientWidth     =   6630
   LinkTopic       =   "Form1"
   ScaleHeight     =   5715
   ScaleWidth      =   6630
   Begin VB.TextBox txtWebPage 
      Height          =   3735
      Left            =   240
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   5
      Top             =   1920
      Width           =   6255
   End
   Begin VB.TextBox txtlocation 
      Height          =   375
      Left            =   480
      TabIndex        =   3
      Text            =   "/~vb/index.html"
      Top             =   960
      Width           =   5655
   End
   Begin VB.TextBox txtwebserver 
      Height          =   375
      Left            =   480
      TabIndex        =   1
      Text            =   "yaweb.sc.cninfo.net"
      Top             =   240
      Width           =   2415
   End
   Begin VB.CommandButton cmdconnect 
      Caption         =   "Connect"
      Height          =   375
      Left            =   2160
      TabIndex        =   0
      Top             =   1440
      Width           =   2055
   End
   Begin MSWinsockLib.Winsock Winsock1 
      Left            =   120
      Top             =   1440
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.Label Label2 
      Caption         =   "Complete Location"
      Height          =   255
      Left            =   480
      TabIndex        =   4
      Top             =   720
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Web Server"
      Height          =   255
      Left            =   480
      TabIndex        =   2
      Top             =   0
      Width           =   1815
   End
End
Attribute VB_Name = "frmdownload"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmdconnect_Click()
On Error Resume Next

  Winsock1.RemoteHost = txtwebserver.Text
  Winsock1.RemotePort = 80
  Winsock1.Connect
  
End Sub

Private Sub Winsock1_Connect()
On Error Resume Next
  Dim strCommand As String
  Dim strWebPage As String
  
  
  strWebPage = txtlocation.Text
  strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
  strCommand = strCommand + "Accept: */*" + vbCrLf
  strCommand = strCommand + "Accept: text/html" + vbCrLf
  strCommand = strCommand + vbCrLf
  Winsock1.SendData strCommand
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  On Error Resume Next
  Dim webData As String
  
  Winsock1.GetData webData, vbString
  txtWebPage.Text = txtWebPage.Text + webData
End Sub

⌨️ 快捷键说明

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