vfp 读取串口数据

来源:百度知道 编辑:UC知道 时间:2024/09/23 10:30:46
我用单片机把检测到得温度通过串口传送到计算机,我用VFP做了一个表单,里面有一个文本框和一个按钮和一个ole控件,我想按下按钮后每隔30从串口读取单片机传来的数据并显示在文本框中,请问代码怎样写 先谢谢各位达人了

相对来说 VB 比较简单的

用 vfp 的人 非常少了

给你 VB程序,供参考!
Private Sub Form_Load()

Timer1.Interval = 3000

MSComm1.CommPort = 1 'com1,maybe other com port
MSComm1.Settings = "9600,N,8,1" 'default setting

MSComm1.PortOpen = True 'open the com

End Sub

Private Sub Timer1_Timer()
If MSComm1.InBufferCount > 0 Then
Text1.Text = Text1.Text + MSComm1.Input + vbCrLf
End If

End Sub