com口发ASCII Y
各位大师:我现在想实现 如何在串口发送“Y”(ASCII)后,看是否能收到“SM”,如能收到,则没有任何提示,若没有收到“SM”。则提示“通讯错误”
谢谢!
[解决办法]
Option ExplicitPrivate Sub Command1_Click() If MSComm1.PortOpen = True Then MSComm1.Object = "Y" End IfEnd SubPrivate Sub Form_Load() MSComm1.Settings = "9600,n,8,1" MSComm1.PortOpen = True MSComm1.RThreshold = 1End SubPrivate Sub MSComm1_OnComm() Select Case MSComm1.CommEvent Case 2 strsj = strsj & MSComm1.Input If Mid(strsj, 1, 2) <> "SM" Then Label1 = "通讯错误" End If End SelectEnd Sub