其中关于读取数据的代码来自下面的vfp程序,不知道我转换的对不对?*** ActiveX 控件事件 *** this.enabled=.t. this.interval=250 If thisform.comm2.PortOpen = .f. thisform.comm2.PortOpen = .T. Else if thisform.comm2.dtrenable=.t. thisform.comm2.inputlen=30 if thisform.comm2.inbuffersize>15 *.or. thisform.comm2.inbuffercount<5 a = thisform.comm2.Input endif e =at(chr(02),a,1) if e<>0 b = substr(a, e + 5, 5) c = Val(b) thisform.Text5.value =C * STR(C) d = substr(a, e + 2, 1) If d = "4" .Or. d = "<" Then thisform.Text5.value = "超载!" EndIf If d = "2" .Or. d = ":" .Or. d = "3" .Or. d = ";" thisform.Text5.value = -C *'-'+STR(C) EndIf If d = "8" .Or. d = "0" .Or. d = "1" Or d = "9" thisform.Text5.value = C *STR(C) EndIf endif thisform.comm2.input endif EndIf
你的波特率等等参数和该com口设置不匹配,或电子称和com口设置不匹配!
to pboy()不是的,因为下面的那个vfp的它的settings:='2400,e,7,1'我的也是啊,电子秤的为波特率为,4800,我改了,也不好用啊
this.enabled=.t.
this.interval=250
If thisform.comm2.PortOpen = .f.
thisform.comm2.PortOpen = .T.
Else
if thisform.comm2.dtrenable=.t.
thisform.comm2.inputlen=30
if thisform.comm2.inbuffersize>15
*.or. thisform.comm2.inbuffercount<5
a = thisform.comm2.Input
endif
e =at(chr(02),a,1)
if e<>0
b = substr(a, e + 5, 5)
c = Val(b)
thisform.Text5.value =C
* STR(C)
d = substr(a, e + 2, 1)
If d = "4" .Or. d = "<" Then
thisform.Text5.value = "超载!"
EndIf
If d = "2" .Or. d = ":" .Or. d = "3" .Or. d = ";"
thisform.Text5.value = -C
*'-'+STR(C)
EndIf
If d = "8" .Or. d = "0" .Or. d = "1" Or d = "9"
thisform.Text5.value = C
*STR(C)
EndIf
endif
thisform.comm2.input
endif
EndIf
Sleep(1000);