数据表中的字段‘zllx'类型是char(1),可能的值是0,1,2,[a-z]case DataModule1.zlzl_ADOQuery.fieldbyname('zllx').Asstring of
0 : RzRadioButton1.Checked:=true;
1 : RzRadioButton2.Checked:=true;
2 : RzRadioButton4.Checked:=true;
else
RzRadioButton3.Checked:=true;
end;
运行时,这个代码报错。
如果,运行这段程序
case DataModule1.zlzl_ADOQuery.fieldbyname('zllx').AsInteger of
0 : RzRadioButton1.Checked:=true;
1 : RzRadioButton2.Checked:=true;
2 : RzRadioButton4.Checked:=true;
else
RzRadioButton3.Checked:=true;
end;
当遇到‘zllx’的值为[a-z]时,肯定报类型错误报告!请高手指教,谢谢!
0 : RzRadioButton1.Checked:=true;
1 : RzRadioButton2.Checked:=true;
2 : RzRadioButton4.Checked:=true;
else
RzRadioButton3.Checked:=true;
end;
运行时,这个代码报错。
如果,运行这段程序
case DataModule1.zlzl_ADOQuery.fieldbyname('zllx').AsInteger of
0 : RzRadioButton1.Checked:=true;
1 : RzRadioButton2.Checked:=true;
2 : RzRadioButton4.Checked:=true;
else
RzRadioButton3.Checked:=true;
end;
当遇到‘zllx’的值为[a-z]时,肯定报类型错误报告!请高手指教,谢谢!
s: String;
c: char;s := Trim(DataModule1.zlzl_ADOQuery.fieldbyname('zllx').Asstring);
c := '';
if (s <> '') then c := s[1];
case c of
'0' : RzRadioButton1.Checked:=true;
'1' : RzRadioButton2.Checked:=true;
.....
'0' : RzRadioButton1.Checked:=true;
'1' : RzRadioButton2.Checked:=true;
'2' : RzRadioButton4.Checked:=true;
else
RzRadioButton3.Checked:=true;
end;