下面是一个点对点的文件传送的部分代码,出错部分已标出
谁能改啊????
blockSize = 1024Dim tempComData As String
sckSystem.GetData tempComData, vbStringDim Command As String
Command = Mid(tempComData, 1, 1)'MsgBox command
If Command = CANCEL_TRANSFER Then
    stopSending
End IfIf Command = ENABLE_START Then Command1.Enabled = TrueIf Command = ACCEPT_TRANSFER Then
        DoEvents
        sckSend.Connect
        Do Until sckSend.State = sckConnected ' Wait until connected
            DoEvents
        Loop
        GoTo BeginTransfer
End IfIf Command = CONTINUE_TRANSFER Then
'On Error GoTo ErrorHandler
        ' Adjust blocksize at end so we don't read too much data
        If fileLength - Loc(hIn) <= blockSize  Then 
            blockSize = fileLength - Loc(hIn) + 1  '就是这里出错!!! blocksize小于零了!!!!!!!!!
        End If
        Temp = Space$(blockSize)        '// Allocate the read buffer '上面的语句导致此行出错
        Get hIn, , Temp                 '// Read a block of data
        ret = DoEvents()                '// Check for cancel button event etc.
        If quitNow Then GoTo endIt
        sckSend.SendData Temp           '// Off it goes
        
        'update progress bar
        sizeOfFileSent = sizeOfFileSent + blockSize
        'On Error GoTo endIt             '//
        '''On Error Resume Next
        ProgressBar1.value = sizeOfFileSent
        compLabel.Caption = sizeOfFile & " 中的 " & sizeOfFileSent & " 已发送 " & Int(sizeOfFileSent / sizeOfFile * 100) & "%"
       ' DoEvents
        
        If sizeOfFileSent >= sizeOfFile Then
            cancel.Caption = "关闭"
            sckSystem.SendData CLOSE_TRANSFER
        End If
        Exit Sub
End If
If Command = CLOSE_TRANSFER Then GoTo endIt
Exit Sub
BeginTransfer:
'On Error GoTo ErrorHandler
    hIn = FreeFile
    Open pathToFile For Binary Access Read As hIn
    fileLength = LOF(hIn)
            ' Adjust blocksize at end so we don't read too much data
            If fileLength - Loc(hIn) <= blockSize Then
                    blockSize = fileLength - Loc(hIn) '+ 1
            End If
            Temp = Space$(blockSize)        '// Allocate the read buffer
            Get hIn, , Temp                 '// Read a block of data
            ret = DoEvents()                '// Check for cancel button event etc.
            If quitNow Then GoTo endIt
            sckSend.SendData Temp           '// Off it goes
            
            'update progress bar
            sizeOfFileSent = sizeOfFileSent + blockSize
            'On Error GoTo endIt             '//
            ProgressBar1.value = sizeOfFileSent
            compLabel.Caption = sizeOfFile & " 中的 " & sizeOfFileSent & " 已发送 " & Int(sizeOfFileSent / sizeOfFile * 100) & "%"
        If sizeOfFileSent >= sizeOfFile Then
            cancel.Caption = "关闭"
            sckSystem.SendData CLOSE_TRANSFER
        End If
        Exit Sub
ErrorHandler:                                           '// Always close the file handle
        Close hIn
        'SendFile = False
endIt:
        'cancel.Caption = "Close"
        sckSend.Close   'this severes the data connection, causing the client to save/end the file
        Close hIn
        MsgBox "发送完毕!", 64, ZX
        Unload Me
End Sub