procedure TForm1.yanzhengmima;
var
ole:Olevariant;
k,h:integer;
byte1:byte;
s1:string;
begin
// 驗證密碼
s100 := ComboBox7.Text;
checkdata(s100);
if length(s100)<>12 then
begin
showmessage('輸入錯誤,輸入的字符長度和要求不符,請仔細檢查。');
exit;
end;
initcomm;
comm.RThreshold:=0;
if comm.PortOpen=false then
comm.PortOpen:=true;
comm.DTREnable:=true;
comm.RTSEnable:=true;
ole:=VarArrayCreate([0 ,15],varByte);
ole[0]:= $4D;
ole[1]:= $4D;
for k:=1 to 12 do
begin
ole[k+1]:= ord(s100[k]);
end;
ole[14]:= $0D;
for h:= 1 to 14 do
begin
byte1:= byte1 + ole[h];
end;
s1 := inttohex(byte1 mod 256,2) ;
ole[15]:= strtoint('$'+s1);
comm.Output := ole;
sleep(50);
ole:=Comm.Input;
if ole[0] = $DD then
begin
show.Lines.Add('操作成功');
success:= true;
end
else if ole[0] = $AA then
show.Lines.Add('操作失敗')
else
exit;
end;
第一次點擊這個按鈕就沒問題,要是連續第二次點擊就出現variant array index of bounds的錯誤。
uj5u.com熱心網友回復:
http://download.csdn.net/detail/veron_04/1777027轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/126315.html
上一篇:記憶體映射執行exe檔案
