'=========发送文件事件================
Public Sub 发送文件(Filename As String)
Dim temp As String, k As Byte, textline As String
'初始化端口
初始化端口 端口参数()
Form1.ProgressBar1.value = 0 '清空进度条
temp = Filename
Do While InStr(temp, "\") <> 0
temp = Mid(temp, InStr(temp, "\") + 1)
DoEvents
Loop
Form1.StatusBar1.Panels(2).Text = "发送文件:" & temp
Open Filename For Input As #1
文件总字符数 = 0
Do While Not EOF(1)
temp = Input(1, #1)
文件总字符数 = 文件总字符数 + 1 '获得总字符数
DoEvents
Loop
Close #1
temp = ""
Open Filename For Input As #1
Do While Not EOF(1)
Do While 传输控制指令 = False '控制传输启停
Form1.Shape2.FillColor = RGB(0, 0, 0)
DoEvents
Loop
textline = Input(1, #1)
Form1.Shape2.FillColor = RGB(255, 0, 0)
k = Asc(textline) '获取当前字符的ASCII值
textline = UCase$(textline) '转换当前字符中的字母为大写字母
Form1.MSComm1.Output = textline '将字符发送到端口发送取
当前字符数 = 当前字符数 + 1
If k <> 10 Then
temp = temp & textline
Else
Form1.Text1.Text = Form1.Text1.Text & temp & Chr(13) & Chr(10)
temp = ""
End If
Form1.MSComm1.InBufferCount = 0
DoEvents
Loop
Close #1
结束端口
End Sub
'=========发送文件事件结束============
05-03-09 11:01