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

📄 form1.frm

📁 很好的vb编程教程
💻 FRM
字号:
VERSION 5.00
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Begin VB.Form Form1 
   Caption         =   "Ftp下载"
   ClientHeight    =   4185
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5895
   LinkTopic       =   "Form1"
   ScaleHeight     =   4185
   ScaleWidth      =   5895
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame1 
      Caption         =   "登录设置"
      Height          =   1815
      Left            =   0
      TabIndex        =   4
      Top             =   0
      Width           =   4455
      Begin VB.TextBox Text1 
         Height          =   350
         Left            =   1560
         TabIndex        =   8
         Top             =   240
         Width           =   2655
      End
      Begin VB.TextBox Text2 
         Height          =   350
         Left            =   1560
         TabIndex        =   7
         Text            =   $"Form1.frx":0000
         Top             =   720
         Width           =   1215
      End
      Begin VB.TextBox Text3 
         Height          =   350
         IMEMode         =   3  'DISABLE
         Left            =   1560
         PasswordChar    =   "*"
         TabIndex        =   6
         Top             =   1200
         Width           =   1215
      End
      Begin VB.CheckBox Check1 
         Caption         =   "匿名登录"
         Height          =   375
         Left            =   3120
         TabIndex        =   5
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label Label1 
         Caption         =   "服务器IP或名称"
         Height          =   372
         Left            =   120
         TabIndex        =   11
         Top             =   360
         Width           =   1332
      End
      Begin VB.Label Label2 
         Caption         =   "用户名称"
         Height          =   375
         Left            =   240
         TabIndex        =   10
         Top             =   840
         Width           =   735
      End
      Begin VB.Label Label3 
         Caption         =   "密码"
         Height          =   375
         Left            =   240
         TabIndex        =   9
         Top             =   1200
         Width           =   1095
      End
   End
   Begin VB.CommandButton Command3 
      Caption         =   "退出程序"
      Height          =   375
      Left            =   4560
      TabIndex        =   3
      Top             =   1440
      Width           =   1100
   End
   Begin VB.CommandButton Command2 
      Caption         =   "中断连接"
      Height          =   375
      Left            =   4560
      TabIndex        =   2
      Top             =   840
      Width           =   1100
   End
   Begin MSComctlLib.ListView ListView1 
      Height          =   1935
      Left            =   0
      TabIndex        =   1
      Top             =   2040
      Width           =   4455
      _ExtentX        =   7858
      _ExtentY        =   3413
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      _Version        =   393217
      Icons           =   "ImageList1"
      SmallIcons      =   "ImageList1"
      ColHdrIcons     =   "ImageList1"
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   0
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   4800
      Top             =   2040
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   32
      ImageHeight     =   32
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   2
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0005
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0459
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.CommandButton Command1 
      Caption         =   "连接"
      Height          =   375
      Left            =   4560
      TabIndex        =   0
      Top             =   240
      Width           =   1100
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   500
      Left            =   4920
      Top             =   2760
   End
   Begin InetCtlsObjects.Inet Inet1 
      Left            =   4800
      Top             =   3360
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      AccessType      =   1
      Protocol        =   2
      RemotePort      =   21
      URL             =   "ftp://"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strDirectory As String
Dim InetState As String

Private Sub Check1_Click()
If Check1.Value = 1 Then
  Text2.Text = "anonymous"
  Text3.Text = "aldl@263.net"
Else
  Text2.Text = ""
  Text3.Text = ""
End If
End Sub

Private Sub Command1_Click()
Dim i As Integer, temp As String, strurl As String
On Error GoTo Handle

  strurl = Text1.Text
  Inet1.UserName = Text2.Text
  Inet1.Password = Text3.Text
   For i = 1 To 4 '处理输入的URL
    temp = Mid(strurl, i, 1)
     If Asc(temp) <= Asc("z") And Asc(temp) >= Asc("a") Then
      strurl = Left(strurl, i - 1) + StrConv(temp, vbUpperCase) + Right(strurl, Len(strurl) - i)
     End If
   Next i
   If Left$(strurl, 6) = "FTP://" Then
    Inet1.Execute strurl
   Else
    Inet1.Execute "ftp://" & strurl
   End If
  Timer1.Enabled = True
Handle:
End Sub

Private Sub Command2_Click()
   Inet1.Cancel
   ListView1.ListItems.Clear
End Sub

Private Sub Command3_Click()
  End
End Sub

Private Sub Form_Load()
   ListView1.View = 0 '使用大图标格式
      
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
   InetState = State
   DoEvents
End Sub





Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)

End Sub

Private Sub Text1_Change()

End Sub

Private Sub Text2_Change()

End Sub

Private Sub Text3_Change()

End Sub

Private Sub Timer1_Timer()
  DoEvents
  '监视连接状态
   If InetState = 12 Then
    Timer1.Enabled = False
    Dim iFile As Integer
    Dim strBuff As String
    
    strBuff = Inet1.GetChunk(1024)
    iFile = FreeFile()
    
    'Len1 = Len(strBuff)
    
    FillList (strBuff)
   
    End If
End Sub


Private Sub FillList(dirName As String)
 '处理返回的目录信息
 Dim i As Integer, i1 As Integer, i2 As Integer, j As Integer
 Dim nodexx As ListItem, ss As String, filen As String
 Dim TL As Boolean
 ListView1.ListItems.Clear
  i2 = 0
  
1:
 i1 = Len(dirName)
 TL = False
 For i = 1 To i1
   ss = Mid(dirName, i, 1)
   aa = Asc(ss)
 If aa = 13 Then
 
  filen = Mid(dirName, 1, i - 1)
  If Len(filen) >= 1 Then
    i2 = i2 + 1
  For j = 1 To Len(filen)
    If Mid(filen, j, 1) = "/" Then
      TL = True
      filen = Mid(filen, 1, j - 1)
      Exit For
    End If
  Next j
   If TL Then
     Set nodexx = ListView1.ListItems.Add(i2, filen, filen, 1)
   Else
     Set nodexx = ListView1.ListItems.Add(i2, filen, filen, 2)
   End If
   ListView1.View = 0
   dirName = Mid(dirName, i + 2, i1 - i - 2)
   GoTo 1
   End If
 End If
Next i
End Sub

⌨️ 快捷键说明

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