if (mscomm1.InBufferSize >15) or (mscomm1.InBufferSize <5) then readstr:=mscomm1.input;
应改为if (mscomm1.InBufferSize >15) then readstr:=mscomm1.input;

解决方案 »

  1.   

    其中关于读取数据的代码来自下面的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
      

  2.   

    你的波特率等等参数和该com口设置不匹配,或电子称和com口设置不匹配!
      

  3.   

    to pboy()不是的,因为下面的那个vfp的它的settings:='2400,e,7,1'我的也是啊,电子秤的为波特率为,4800,我改了,也不好用啊
      

  4.   

    推荐你一个串口调试工具(http://cicn.51.net/downsoft.php?softid=76),更改各个参数,你可以很直观的看到数据。在把正确的参数,赋到程序中,就ok啦。记得给分啊!
      

  5.   

    发送完信号请延时。
    Sleep(1000);