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

📄 form1.vb

📁 Visual.Basic.NET实用编程百例-47.6M.zip
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.Command2.BackColor = System.Drawing.SystemColors.Control
        Me.Command2.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command2.Location = New System.Drawing.Point(360, 64)
        Me.Command2.Name = "Command2"
        Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command2.Size = New System.Drawing.Size(74, 25)
        Me.Command2.TabIndex = 2
        Me.Command2.Text = "中断连接"
        '
        'ListView1
        '
        Me.ListView1.Location = New System.Drawing.Point(0, 136)
        Me.ListView1.Name = "ListView1"
        Me.ListView1.OcxState = CType(resources.GetObject("ListView1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ListView1.Size = New System.Drawing.Size(321, 145)
        Me.ListView1.TabIndex = 1
        '
        'ImageList1
        '
        Me.ImageList1.Enabled = True
        Me.ImageList1.Location = New System.Drawing.Point(368, 144)
        Me.ImageList1.Name = "ImageList1"
        Me.ImageList1.OcxState = CType(resources.GetObject("ImageList1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageList1.Size = New System.Drawing.Size(38, 38)
        Me.ImageList1.TabIndex = 5
        '
        'Command1
        '
        Me.Command1.BackColor = System.Drawing.SystemColors.Control
        Me.Command1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command1.Location = New System.Drawing.Point(360, 32)
        Me.Command1.Name = "Command1"
        Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command1.Size = New System.Drawing.Size(74, 25)
        Me.Command1.TabIndex = 0
        Me.Command1.Text = "连接"
        '
        'Timer1
        '
        Me.Timer1.Interval = 500
        '
        'Inet1
        '
        Me.Inet1.Enabled = True
        Me.Inet1.Location = New System.Drawing.Point(368, 208)
        Me.Inet1.Name = "Inet1"
        Me.Inet1.OcxState = CType(resources.GetObject("Inet1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.Inet1.Size = New System.Drawing.Size(38, 38)
        Me.Inet1.TabIndex = 6
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(439, 292)
        Me.Controls.Add(Me.Frame1)
        Me.Controls.Add(Me.Command3)
        Me.Controls.Add(Me.Command2)
        Me.Controls.Add(Me.ListView1)
        Me.Controls.Add(Me.ImageList1)
        Me.Controls.Add(Me.Command1)
        Me.Controls.Add(Me.Inet1)
        Me.Cursor = System.Windows.Forms.Cursors.Default
        Me.Location = New System.Drawing.Point(4, 24)
        Me.Name = "Form1"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text = "连接FTP"
        Me.Frame1.ResumeLayout(False)
        CType(Me.ListView1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.ImageList1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.Inet1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
#End Region
    Dim strDirectory As String
    Dim InetState As String

    Private Sub Check1_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Check1.CheckStateChanged
        If Check1.CheckState = 1 Then
            Text2.Text = "anonymous"
            Text3.Text = "aldl@263.net"
        Else
            Text2.Text = ""
            Text3.Text = ""
        End If
    End Sub

    Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
        Dim i As Short
        Dim temp, strurl As String
        On Error GoTo Handle_Renamed

        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 = VB.Left(strurl, i - 1) & StrConv(temp, VbStrConv.UpperCase) & VB.Right(strurl, Len(strurl) - i)
            End If
        Next i
        If VB.Left(strurl, 6) = "FTP://" Then
            Inet1.Execute(strurl)
        Else
            Inet1.Execute("ftp://" & strurl)
        End If
        Timer1.Enabled = True
Handle_Renamed:
    End Sub

    Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
        Inet1.Cancel()
        ListView1.ListItems.Clear()
    End Sub

    Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click
        End
    End Sub

    Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
        ListView1.View = 0 '使用大图标格式

    End Sub

    Private Sub Inet1_StateChanged(ByVal eventSender As System.Object, ByVal eventArgs As AxInetCtlsObjects.DInetEvents_StateChangedEvent) Handles Inet1.StateChanged
        InetState = CStr(eventArgs.state)
        System.Windows.Forms.Application.DoEvents()
    End Sub

    Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
        System.Windows.Forms.Application.DoEvents()
        '监视连接状态
        Dim iFile As Short
        Dim strBuff As String
        If CDbl(InetState) = 12 Then
            Timer1.Enabled = False

            strBuff = Inet1.GetChunk(1024)
            iFile = FreeFile()

            'Len1 = Len(strBuff)

            FillList((strBuff))

        End If
    End Sub
    Private Sub FillList(ByRef dirName As String)
        Dim aa As Object
        '处理返回的目录信息
        Dim i2, i, i1, j As Short
        Dim nodexx As MSComctlLib.ListItem
        Dim ss, 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
                        nodexx = ListView1.ListItems.Add(i2, filen, filen, 1)
                    Else
                        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
End Class

⌨️ 快捷键说明

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