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

📄 formtx.frm

📁 I implemented a perfect file transfer OCX client/server. I created a perfect function to parse and s
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form FormTX 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "Client"
   ClientHeight    =   6600
   ClientLeft      =   45
   ClientTop       =   285
   ClientWidth     =   7185
   Icon            =   "FormTX.frx":0000
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6600
   ScaleWidth      =   7185
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdSetParam 
      Caption         =   "Set parameters"
      Height          =   330
      Left            =   2940
      TabIndex        =   22
      Top             =   1500
      Width           =   1800
   End
   Begin VB.TextBox txtDelay 
      Appearance      =   0  'Flat
      Height          =   285
      Left            =   1680
      TabIndex        =   21
      Text            =   "5"
      Top             =   1680
      Width           =   645
   End
   Begin VB.TextBox txtBuff 
      Appearance      =   0  'Flat
      Height          =   285
      Left            =   1680
      TabIndex        =   20
      Text            =   "1024"
      Top             =   1365
      Width           =   645
   End
   Begin VB.TextBox txtRemoteFile 
      Appearance      =   0  'Flat
      Height          =   330
      Left            =   1260
      TabIndex        =   13
      Text            =   "c:\"
      Top             =   840
      Width           =   3795
   End
   Begin VB.PictureBox picDir 
      BorderStyle     =   0  'None
      Height          =   225
      Left            =   5060
      Picture         =   "FormTX.frx":6482
      ScaleHeight     =   225
      ScaleWidth      =   330
      TabIndex        =   12
      Top             =   470
      Width           =   330
   End
   Begin VB.TextBox txtLocalFile 
      Appearance      =   0  'Flat
      Height          =   330
      Left            =   1260
      TabIndex        =   10
      Top             =   420
      Width           =   3795
   End
   Begin MSComDlg.CommonDialog cd 
      Left            =   5460
      Top             =   630
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.TextBox txtRemoteHost 
      Appearance      =   0  'Flat
      Height          =   330
      Left            =   1260
      TabIndex        =   8
      Text            =   "localhost"
      Top             =   0
      Width           =   3795
   End
   Begin VB.CommandButton cmdBrkTrf 
      Caption         =   "Break transfer"
      Height          =   330
      Left            =   1365
      TabIndex        =   4
      Top             =   2415
      Width           =   1380
   End
   Begin client.ctlFtp ctlFtpTX 
      Left            =   6300
      Top             =   630
      _ExtentX        =   847
      _ExtentY        =   847
   End
   Begin VB.CommandButton cmdSendFile 
      Caption         =   "Send file"
      Height          =   330
      Left            =   0
      TabIndex        =   3
      Top             =   2415
      Width           =   1380
   End
   Begin VB.CommandButton cmdDisconnect 
      Caption         =   "Close conn."
      Height          =   330
      Left            =   6090
      TabIndex        =   1
      Top             =   0
      Width           =   1065
   End
   Begin VB.CommandButton cmdConnect 
      Caption         =   "Open conn."
      Height          =   330
      Left            =   5040
      TabIndex        =   0
      Top             =   0
      Width           =   1065
   End
   Begin VB.TextBox txtStatus 
      Appearance      =   0  'Flat
      BackColor       =   &H00000000&
      BeginProperty Font 
         Name            =   "Terminal"
         Size            =   9
         Charset         =   255
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000FF00&
      Height          =   3270
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   2
      Top             =   3255
      Width           =   7155
   End
   Begin VB.Line Line4 
      X1              =   2625
      X2              =   2940
      Y1              =   1680
      Y2              =   1680
   End
   Begin VB.Line Line3 
      X1              =   2310
      X2              =   2625
      Y1              =   2100
      Y2              =   2100
   End
   Begin VB.Line Line2 
      X1              =   2625
      X2              =   2625
      Y1              =   1260
      Y2              =   2100
   End
   Begin VB.Line Line1 
      X1              =   2310
      X2              =   2625
      Y1              =   1260
      Y2              =   1260
   End
   Begin VB.Label Label8 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Delay sending packets"
      ForeColor       =   &H00008000&
      Height          =   225
      Left            =   0
      TabIndex        =   19
      Top             =   1680
      Width           =   1695
   End
   Begin VB.Label Label7 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Buffer size"
      ForeColor       =   &H00008000&
      Height          =   225
      Left            =   0
      TabIndex        =   18
      Top             =   1365
      Width           =   1695
   End
   Begin VB.Label Label6 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Bytes remaining"
      ForeColor       =   &H00800000&
      Height          =   225
      Left            =   4830
      TabIndex        =   17
      Top             =   2835
      Width           =   2325
   End
   Begin VB.Label Label5 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Bytes sent"
      ForeColor       =   &H00FF0000&
      Height          =   225
      Left            =   2415
      TabIndex        =   16
      Top             =   2835
      Width           =   2325
   End
   Begin VB.Label Label4 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Total lenght"
      ForeColor       =   &H00FF8080&
      Height          =   225
      Left            =   0
      TabIndex        =   15
      Top             =   2835
      Width           =   2325
   End
   Begin VB.Label Label3 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "File remote"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   330
      Left            =   0
      TabIndex        =   14
      Top             =   840
      Width           =   1275
   End
   Begin VB.Label Label2 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "File local"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   330
      Left            =   0
      TabIndex        =   11
      Top             =   420
      Width           =   1275
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Remote Host"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   330
      Left            =   0
      TabIndex        =   9
      Top             =   0
      Width           =   1275
   End
   Begin VB.Label lblTotBytes 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H00FF8080&
      Height          =   225
      Left            =   0
      TabIndex        =   7
      Top             =   3045
      Width           =   2325
   End
   Begin VB.Label lblBytesSent 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H00FF0000&
      Height          =   225
      Left            =   2415
      TabIndex        =   6
      Top             =   3045
      Width           =   2325
   End
   Begin VB.Label lblBytesRemaining 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H00800000&
      Height          =   225
      Left            =   4830
      TabIndex        =   5
      Top             =   3045
      Width           =   2325
   End
End
Attribute VB_Name = "FormTX"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Private Sub Form_Load()
    setButton False
End Sub

Private Sub cmdSetParam_Click()
    setParam
End Sub

Private Sub setParam()
     With ctlFtpTX
        .timeSwap = CInt(txtDelay.Text)
        .bufferSize = CLng(txtBuff.Text)
    End With
End Sub

Private Sub cmdBrkTrf_Click()
    If ctlFtpTX.Status = sck_Connected Then ctlFtpTX.breakTransfer
End Sub

Private Sub cmdConnect_Click()
    txtStatus.Text = txtStatus.Text & "Waiting to connect..." & vbCrLf
    cmdConnect.Enabled = False
    
    With ctlFtpTX
        .timeSwap = CInt(txtDelay.Text)
        .bufferSize = CLng(txtBuff.Text)
        .remoteHost = txtRemoteHost.Text
        .remotePort = 20000
        .Connect
    End With
    
End Sub

Private Sub cmdDisconnect_Click()
    
    ctlFtpTX.CloseSck
    
    If ctlFtpTX.Status = sck_Closed Then
        txtStatus.Text = txtStatus.Text & "No active connection..." & vbCrLf
    Else
        txtStatus.Text = txtStatus.Text & "Connection in append..." & vbCrLf
    End If
    
    setButton False
End Sub

Private Sub cmdSendFile_Click()
    ' put the file to transfer
    If txtLocalFile.Text <> "" And ctlFtpTX.Status = sck_Connected Then
        ctlFtpTX.sendFile txtLocalFile.Text, txtRemoteFile.Text
    Else
        MsgBox "Select a valid local file to send out!", vbCritical
    End If
End Sub

Private Sub ctlFtpTX_CloseSck()
    txtStatus.Text = txtStatus.Text & "The remote connection has closed by server..." & vbCrLf
    ctlFtpTX.CloseSck
    setButton False
End Sub

Private Sub ctlFtpTX_Connect()
    txtStatus.Text = txtStatus.Text & "Remote host connected..." & vbCrLf
    setButton True
End Sub

Private Sub ctlFtpTX_Error(ByVal Number As Integer, Description As String, ByVal sCode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    txtStatus.Text = txtStatus.Text & "errore: N." & Number & "- desc. " & Description & vbCrLf
    ctlFtpTX.CloseSck
    setButton False
End Sub

Private Sub ctlFtpTX_fileBytesSent(ByVal bytesTotal As Double, ByVal bytesSent As Double, ByVal bytesRemaining As Double)
    lblTotBytes.Caption = Format(bytesTotal, "##,##0")
    lblBytesRemaining.Caption = Format(bytesRemaining, "##,##0")
    lblBytesSent.Caption = Format(bytesSent, "##,##0")
End Sub

Private Sub ctlFtpTX_TransferComplete()
    MsgBox "Transfer complete!"
End Sub

Private Sub picDir_Click()
    cd.CancelError = False
    On Error GoTo errH
    
    picDir.BorderStyle = 1
        cd.DialogTitle = "Select file to send"
        cd.ShowOpen
        txtLocalFile.Text = cd.FileName
    
    picDir.BorderStyle = 0
Exit Sub
errH:

End Sub

Private Sub setButton(bCnActive As Boolean)
    cmdConnect.Enabled = Not bCnActive
    cmdDisconnect.Enabled = bCnActive
End Sub

⌨️ 快捷键说明

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