这是我对一个单选组件的事件代码,为什么反馈的值总是最后一行的a:=636; t:=706; o:=630;
procedure TForm1.RadioButton2Click(Sender: TObject);var
str:PChar;
begin
if (RadioGroup1.ItemIndex=0) then
str:='14';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=15; o:=14; end;
str:='18';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=19; o:=18; end;
str:='25';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=26; o:=25; end;
str:='32';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=33; o:=32; end;
str:='38';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=39; o:=38; end;
str:='45';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=46; o:=45; end;
str:='57';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=59; o:=57; end;
str:='76';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=78; o:=76; end;
str:='89';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=91; o:=89; end;
str:='108';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=110; o:=108; end;
str:='133';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=135; o:=133; end;
str:='159';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=161; o:=159; end;
str:='219';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=222; o:=219; end;
str:='273';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=276; o:=273; end;
str:='325';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=328; o:=325; end;
str:='377';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=381; o:=377; end;
str:='426';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=430; o:=426; end;
str:='480';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=485; o:=480; end;
str:='530';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=535; o:=530; end;
str:='630';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=636; o:=630; end;
str:='720';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=724; o:=720; end;
str:='820';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=824; o:=820; end;
str:='920';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=924; o:=920; end;
str:='1020';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=1024; o:=1020; end;
str:='1220';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=1224; o:=1220; end;
str:='1420';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=1424; o:=1420; end;
str:='1620';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=1624; o:=1620; end;
str:='1820';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=1824; o:=1820; end;
str:='2020';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=2024; o:=2020; end; 第一个问题:本来这个是最后一行的,但是最后一行的返回值总是错误的,与其他办法么?我迫不得已加上了下面一行,设定一个肯定用不到的数‘22222’,暂时解决的。
str:='22222';
if StrLComp(PChar(Edit4.text),str,5)=0 then
begin m:=22222; o:=22222; end;
Edit8.Text:=FloatToStr(m);
Edit9.Text:=FloatToStr(o);
if (RadioGroup1.ItemIndex=1) then
begin
if ((p=25) and (q=10))then
str:='14'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=15; t:=30; o:=14; end;
if ((p=25) and (q=15))then
str:='18'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=19; t:=35; o:=18; end;
if ((p=25) and (q=20))then
str:='25'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=26; t:=45; o:=25; end;
if ((p=25) and (q=25))then
str:='32'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=33; t:=52; o:=32; end;
if ((p=25) and (q=32))then
str:='38'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=39; t:=60; o:=38; end;
if ((p=25) and (q=40))then
str:='45'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=46; t:=70; o:=45; end;
if ((p=25) and (q=50))then
str:='57'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=59; t:=84; o:=57; end;
if ((p=25) and (q=65))then
str:='76'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=78; t:=104; o:=76; end;
if ((p=25) and (q=80))then
str:='89'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=91; t:=118; o:=89; end;
if ((p=25) and (q=100))then
str:='108'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=110; t:=145; o:=108; end;
if ((p=40) and (q=10))then
str:='14'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=15; t:=30; o:=14; end;
if ((p=40) and (q=15))then
str:='18'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=19; t:=35; o:=18; end;
if ((p=40) and (q=20))then
str:='25'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=26; t:=45; o:=25; end;
if ((p=40) and (q=25))then
str:='32'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=33; t:=52; o:=32; end;
if ((p=40) and (q=32))then
str:='38'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=39; t:=60; o:=38; end;
if ((p=40) and (q=40))then
str:='45'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=46; t:=70; o:=45; end;
if ((p=40) and (q=50))then
str:='57'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=59; t:=84; o:=57; end;
if ((p=40) and (q=65))then
str:='76'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=78; t:=104; o:=76; end;
if ((p=40) and (q=80))then
str:='89'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=91; t:=118; o:=89; end;
if ((p=40) and (q=100))then
str:='108'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=110; t:=145; o:=108; end;
if ((p=40) and (q=125))then
str:='133'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=135; t:=170; o:=133; end;
if ((p=40) and (q=150))then
str:='159'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=161; t:=200; o:=159; end;
if ((p=40) and (q=200))then
str:='219'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=222; t:=260; o:=219; end;
if ((p=40) and (q=250))then
str:='273'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=276; t:=312; o:=273; end;
if ((p=40) and (q=300))then
str:='325'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=328; t:=380; o:=325; end;
if ((p=40) and (q=350))then
str:='377'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=381; t:=444; o:=377; end;
if ((p=40) and (q=400))then
str:='426'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=430; t:=518; o:=426; end;
if ((p=40) and (q=450))then
str:='480'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=485; t:=545; o:=480; end;
if ((p=40) and (q=500))then
str:='530'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=535; t:=598; o:=530; end;
if ((p=40) and (q=600))then
str:='630'; if StrLComp(PChar(Edit4.text),str,5)=0 then
begin a:=636; t:=706; o:=630; end; 第二个问题:这个返回值,居然总是返回最后一行的 a:=636; t:=706; o:=630; 这几个数,这个语法出在什么问题上啊?
Edit8.Text:=FloatToStr(m);
Edit9.Text:=FloatToStr(o);
Edit10.Text:=FloatToStr(t);
end;
--------------------编程问答-------------------- 没人会么?? --------------------编程问答-------------------- 你都没搞清楚条件语句,应该是
if 条件1 then
begin
end
else if 条件2 then
begin
end
else
begin
end; --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 代码太晃眼了,为什么不用数组呢,看着头都晕了。
另外,干嘛用 strlcomp 这种的。
补充:.NET技术 , 其他语言