944,111 Members | Top Members by Rank

Ad:
Oct 13th, 2009
0

IF and ELSE procedures

Expand Post »
Hi, i am trying to get my application to check, which radiobutton is selected, and then perform instructions based on the selection.

but i cant seem to use a IF and ELSE procedure to do this, can somebody help me out as to what procedure i should use.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
revski is offline Offline
28 posts
since Jul 2009
Oct 13th, 2009
0
Re: IF and ELSE procedures
one form,two radio buttons as radiobutton1 and radiobutton2 and a simple button as button1,place them onto the form and code the button1 as
delphi Syntax (Toggle Plain Text)
  1.  
  2. procedure TForm1.Button1Click(Sender: TObject);
  3. begin
  4. if radiobutton1.Checked = true then begin
  5. radiobutton2.Checked:=false;
  6. showmessage('radiobutton1 is selected');
  7. end else begin
  8. showmessage('radiobutton2 is selected');
  9. end;
  10. end;
this is it.....
Reputation Points: 132
Solved Threads: 138
Posting Pro
FlamingClaw is offline Offline
559 posts
since Feb 2009
Oct 13th, 2009
0
Re: IF and ELSE procedures
or you can use case structure too
delphi Syntax (Toggle Plain Text)
  1.  
  2. procedure TForm1.Button1Click(Sender: TObject);
  3. begin
  4. case radiobutton1.Checked of
  5. true:showmessage('radiobutton1 is selected');
  6. false:showmessage('radiobutton1 is unchecked');
  7. end;
  8. end;

by the way the If..then..else is a structure not procedure
Reputation Points: 132
Solved Threads: 138
Posting Pro
FlamingClaw is offline Offline
559 posts
since Feb 2009
Oct 14th, 2009
0
Re: IF and ELSE procedures
Click to Expand / Collapse  Quote originally posted by revski ...
Hi, i am trying to get my application to check, which radiobutton is selected, and then perform instructions based on the selection.

but i cant seem to use a IF and ELSE procedure to do this, can somebody help me out as to what procedure i should use.
With a Radio group of RG, with 2 radio buttons Radio1 and Radio2 entered in the RG. items property.

Do a Radiogroup on click event and put in the following:

procedure TForm1.RGClick(Sender: TObject);
begin
CASE RG.itemindex OF
0 : { Do something }
1 : { Do Something else }
End;
end;

Alternatively you could trigger the case statement on the press of an apply or OK button.

Hope that helps

PQ
Reputation Points: 11
Solved Threads: 3
Newbie Poster
quaifp1 is offline Offline
10 posts
since Oct 2009
Oct 19th, 2009
0
Re: IF and ELSE procedures
thanks again flamingclaw for your help, sorry havent marked thread as solved sooner, been away working.

Thanks quaifp1 too for your reply.
Reputation Points: 10
Solved Threads: 0
Light Poster
revski is offline Offline
28 posts
since Jul 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Connect to an Oracle database
Next Thread in Pascal and Delphi Forum Timeline: Incompatible Types TString and TCaption when using memos





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC