发表于:2003-11-04 15:31:00
楼主
我正在试验用VB的mscomm控件与OMRON E5AK温控表通讯,DOS下的qbasic通了,但是VB中始终发送出去没有回应,线路没有问题。程序如下,请各位高手帮忙看看,先在这里谢过了!
Private Sub Command1_Click()
fcs = 0
For ifcs = 1 To Len(Text1.Text)
这部分是验证计算 fcs = fcs Xor Asc(Mid$(Text1.Text, ifcs, 1))
不会有问题 Next
fcs1$ = Right$("0" + Hex$(fcs), 2)
sd$ = Text1.Text & fcs1$ & Chr(42)
MSComm1.Output = sd$
End Sub
Private Sub Form_Load()
MSComm1.PortOpen = True
MSComm1.SThreshold = 1
MSComm1.RThreshold = 1
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
Text2.Text = MSComm1.Input
End Select
end sub