翻了最长的OK的过程。produce cmdokonclick()
var
  inarry,outarry:string;
  
  k:integer;
begin
  if length(txtpassword.text)=3 then begin
    k:=1;
        outarry := txtPassword.text;
        outarry := Form1.a1 + outarry;
        repeat
        
        Form1.MSComm1.Output := copy(outarry, k, 1);
        k := k + 1;
        Until k > 4;
        Form1.MSComm1.InputLen = 0;
        Form1.Hide;
        repeat
          Application.ProcessMessage;
        until Form1.MSComm1.InBufferCount >= 1;
        case inarry of
        '!':begin
            showmessage('请先插卡!');
            form1.Hide;
            end;
        '#':begin
             showmessage('无效的密码,请重试!');
             txtpassword.setfocus;
            end;
         '$':begin 
            showmessage('通信错误!请重试!"');
            form1.Hide;
            end;
         '(':begin
         repeat
          Application.ProcessMessage;
        until Form1.MSComm1.InBufferCount >= 27;
        inarry:=form1.mscomm1.input;
        form1.hide;
        Form1.Text1.Text = copy(inarry, 1,5);
            Form1.Text2.Text = copy(inarry, 6, 10);
            Form1.Text3.Text = copy(inarry, 16, 1);
            Form1.Text4.Text = copy(inarry, 17, 8);
            Form1.Text5.Text = copy(inarry, 25, 3);
            end;
            ')' :begin
              form1.hide;
              end;
         end;   
         loginsucceeded:=true;
         form1.hide;
        end
        else begin
        showmessage('无效的密码,请重试');
        txtpassword.setfocus;
       end;
  end;
  
  SendKeys "{Home}+{End}"我不知道怎么来。 

解决方案 »

  1.   

    command4的procedure Command4onClick;
    var
     k: Integer;
    outarry:String;
    begin
    k := 1;
    outarry: = Text6.Text + Text7.Text + Text9.Text + Text8.Text + Text10.Text;
            repeat
            MSComm1.Output = copy(outarry, k, 1);
            k := k + 1;
             Until k > 27;
    end;
      

  2.   

    谢谢了大侠,看来就等着去调试了。
    还有个问题就像
    Private Sub Command3_Click()
    Me.Hide
    MSComm1.PortOpen = False
    End
    End Sub中的Me.Hide和Mscomm1.portopen=false
     怎么DELPHI中编程表示。
      

  3.   

    MSComm1.Output = copy(outarry, k, 1);
    好像编译通不过,我也不知道是什么意思!
            
      

  4.   

    MSComm1.Output = copy(outarry, k, 1);copy后返回的是一个字符的string.output要的是什么类型?好象是char??那用
    s:=copy(outarry, k, 1);
    mscomm1.output:=s[1];还有是:= 不是=
    me.hide
    form1.hide;-----------form1是窗体NAME
    Mscomm1.portopen=false;
    Mscomm1.portopen:=false;