Private Sub Cmdsend_Click()
If Text2.Text = "" Then
pp = MsgBox("发送的数据不能为空!", 0 + 16, "系统提示")
Exit Sub
End If
MSComm1.Output = Trim(Text2.Text)
For i = 1 To 20000000
Next i
End Sub
Private Sub Command1_Click()
MSComm1.PortOpen = False
Unload Me
End Sub
Private Sub Form_Load()
' 串口初始化
MSComm1.CommPort = 3 ' 设置通信端口号为COM1
MSComm1.Settings = "9600,n,8,1" ' 设置串口1参数
MSComm1.InputMode = 0 ' 接收文本型数据
MSComm1.PortOpen = True ' 打开通信端口1
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Timer1_Timer()
Dim buf$
buf = Trim(MSComm1.Input) ' 将缓冲区内的数据读入buf变量中
If Len(buf) <> 0 Then ' 判断缓冲区内是否存在数据
Text1.Text = Text1.Text + Chr(13) + Chr(10) + buf '回车换行
End If
End Sub
发图片看不清楚