S
strchi
Unregistered / Unconfirmed
GUEST, unregistred user!
这是我的一段原程序,目的是找出某个panel上边的RadioButton或TCheckBox的被选的后2项的值
可是不知道怎么搞的,现在突然出错了,我实在是无法排除这个错误,然后把该程序拷贝到
别的程序里面,发现可以执行,不信你可以拷贝这个代码到你的new程序里,然后放一个 panel
放几个RadioButton,是可以输出结果的,
procedure TForm1.Button1Click(Sender: TObject);
begin
button1.Caption:=PnlToStr(Form1,panel1,1);//k:字段长度,h:可选值数目
end;
我已经把错误代码考到下面,恳请高手指点一下小弟
function TMainForm.PnlToStr(Form:Tform;panel:Tpanel;k:integer):string;//k:截取的后面的字段长度
var
J: Integer;
s,s1,sMain:string;
begin
s:='';
for J:= 0 to Form.ComponentCount-1 do
begin
if Form.Components[J].GetParentComponent.Name=Panel.Name then
begin
sMain:=Form.Components[J].Name;
if (form.Components[j] is TRadioButton) and((form.Components[j] as TRadioButton).checked=true) then
begin
s:=s+copy(sMain,length(sMain)-k+1,length(sMain));
end
else if (form.Components[j] is TCheckBox) and ((form.Components[j] as TCheckBox).checked=true) then
begin
s:=s+copy(sMain,length(sMain)-k+1,length(sMain))+';';
end;
end;
end;
s1:=s;
delete(s1,1,pos(';',s)+1); delete(s1,1,pos(';',s1)+1);
if pos(';',s1)<>0 then
begin
if application.MessageBox('每项至多选择二项!','提示',MB_OK+MB_iconquestion)=idOk then
begin//请问有好的限制选择的条件吗?
abort;
end;
end
else
result:=s;
end;
---------------------------
Debugger Exception Notification
---------------------------
Project kjcg.exe raised exception class EAccessViolation with message 'Access violation
at address 004DEAA7 in module 'kjcg.exe'. Read of address 00000008'. Process stopped. Use
Step or Run to continue.
---------------------------
OK Help
---------------------------
可是不知道怎么搞的,现在突然出错了,我实在是无法排除这个错误,然后把该程序拷贝到
别的程序里面,发现可以执行,不信你可以拷贝这个代码到你的new程序里,然后放一个 panel
放几个RadioButton,是可以输出结果的,
procedure TForm1.Button1Click(Sender: TObject);
begin
button1.Caption:=PnlToStr(Form1,panel1,1);//k:字段长度,h:可选值数目
end;
我已经把错误代码考到下面,恳请高手指点一下小弟
function TMainForm.PnlToStr(Form:Tform;panel:Tpanel;k:integer):string;//k:截取的后面的字段长度
var
J: Integer;
s,s1,sMain:string;
begin
s:='';
for J:= 0 to Form.ComponentCount-1 do
begin
if Form.Components[J].GetParentComponent.Name=Panel.Name then
begin
sMain:=Form.Components[J].Name;
if (form.Components[j] is TRadioButton) and((form.Components[j] as TRadioButton).checked=true) then
begin
s:=s+copy(sMain,length(sMain)-k+1,length(sMain));
end
else if (form.Components[j] is TCheckBox) and ((form.Components[j] as TCheckBox).checked=true) then
begin
s:=s+copy(sMain,length(sMain)-k+1,length(sMain))+';';
end;
end;
end;
s1:=s;
delete(s1,1,pos(';',s)+1); delete(s1,1,pos(';',s1)+1);
if pos(';',s1)<>0 then
begin
if application.MessageBox('每项至多选择二项!','提示',MB_OK+MB_iconquestion)=idOk then
begin//请问有好的限制选择的条件吗?
abort;
end;
end
else
result:=s;
end;
---------------------------
Debugger Exception Notification
---------------------------
Project kjcg.exe raised exception class EAccessViolation with message 'Access violation
at address 004DEAA7 in module 'kjcg.exe'. Read of address 00000008'. Process stopped. Use
Step or Run to continue.
---------------------------
OK Help
---------------------------