Dim fs As Variant
Dim a As String Dim i As Long
Dim filepath As String Dim m
filepath = App.Path & "\abc.txt" '文本文檔名稱為 123.txt
Open filepath For Input As #1
Line Input #1, a
Close #1
m = Split(a, ",")
If UBound(m) = 0 Then
Exit Sub '如果發送數據為空則退出過程
ElseIf MSComm1.PortOpen = False Then
MsgBox "串口未打開!", 64, "提示"
Exit Sub
End If
MSComm1.Settings = com_setting fs = Replace(TextSend.Text, " ", "")
For i = LBound(m) To UBound(m)
fs = CStr(Abs(m(i)))
MSComm1.Output = fs
Label11.Caption = Len(strsend) '發送計數
Next i
Close #1
End Sub