Dim sendatalen As Long, gdata(20) As Byte, sdata(20) As Byte, gdata1(10) As Byte, device(11) As Byte
    Dim Command(10) As Byte
    Dim tempno As Long, tkh As String, txfje As Double
    Dim tempcom As String, tempname As String, templeibi As String, tempstno As String
    Dim intmoney As Long
    tempno = Trim(Text1.Text)
    tempcom = Trim(Text2.Text)
    tkh = Trim(Text5.Text)
    
    commandLen = 4
    longg = 9
    Command(0) = tempno
    Command(1) = 111
    Command(2) = 9
    Command(3) = 0
    Command(4) = 0
    device(0) = Asc("C")
    device(1) = Asc("O")
    device(2) = Asc("M")
    device(3) = Asc(tempcom)
    ret = getdata(commandLen, Command(0), longg, gdata(0), device(0))

解决方案 »

  1.   

    看看这样行不?
    var
      SendDataLen: Longint;
      gData: array[0..20] of byte;
      sData: array[0..20] of byte;
      gData1: array[0..20] of byte;
      device: array[0..11] of byte;
      Command: array[0..10] of byte;
      tempno: Longint;
      tkh: string;
      txfje: Double;
      tempCom: string;
      tempname: string;
      templeibi: string;
      tempstno: string;
      intmoney: Longint;
    begin
      tempno := trim(Text1.Text);
      tempcom := Trim(Text2.Text);
      tkh := Trim(Text5.Text);  commandLen := 4;
      longg := 9;
      Command[0] := byte(tempno);
      Command[1] := 111;
      Command[2] := 9;
      Command[3] := 0;
      Command[4] := 0;
      device[0] := ord('C');
      device[1] := ord('O');
      device(2] := ord('M');
      device[3] := ord(tempcom[0]);
      Result = getdata(commandLen, Command[0], longg, gdata[0], device[0]);
    end;
      

  2.   

    var
      sendataleng:longint;
      gdata,sdata:array[0..20] of byte;
      gdata:array[0..10 of Byte;
      device:arrat[0..11] of Byte;
      command[0..10] of byte;
      tempno: Longint;
      tkh: String; 
      txfje: Double;
      tempcom : String;
    begin
        tempno: = Trim(Text1.Text);
        tempcom: = Trim(Text2.Text);
        tkh: = Trim(Text5.Text);
        
        commandLen := 4;
        longg: = 9;
        Command(0): = tempno;
        Command(1): = 111;
        Command(2): = 9;
        Command(3): = 0;
        Command(4): = 0;
        device(0) := ord('C');
        device(1): = ord('O'):
        device(2): = ord('M');
        device(3) := ord(tempcom[0]);
        ret: = getdata(commandLen, Command[0], longg, gdata[0], device[0])
    end;说明:trim 函数是去掉输入控件中前后的空格
      ASC是求ASC吗,如果这里给出的ORD不对的话,去查找一下  tempname: String;
      templeibi: String;
      tempstno : String;
      intmoney : Longint  
      

  3.   

    上面的兄弟,注意一下MS和BORLAND的定义是不一样的。数组的长度存在问题;
    gdata,sdata:array[0..20] of byte;
    应该为gdata,sdata:array[0..19] of byte;其他数组也一样,如果不注意上面这些问题,你和MS的语言做连调的话,会出现你查了N久都不知道错误在哪里。具体代码我就不再说了。
      

  4.   

    奇怪了,我照着楼上的写,运行时可以了,但是返回值不对,vb的正确的是0,而delphi的是2,表示超时,哪位帮忙看看错误出在哪?