IF and ELSE procedures

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2009
Posts: 17
Reputation: revski is an unknown quantity at this point 
Solved Threads: 0
revski revski is offline Offline
Newbie Poster

IF and ELSE procedures

 
0
  #1
Oct 13th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 452
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 108
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training
 
0
  #2
Oct 13th, 2009
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
  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.....
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 452
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 108
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training
 
0
  #3
Oct 13th, 2009
or you can use case structure too
  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
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 10
Reputation: quaifp1 is an unknown quantity at this point 
Solved Threads: 3
quaifp1 quaifp1 is offline Offline
Newbie Poster
 
0
  #4
Oct 14th, 2009
Originally Posted by revski View 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.
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 17
Reputation: revski is an unknown quantity at this point 
Solved Threads: 0
revski revski is offline Offline
Newbie Poster
 
0
  #5
Oct 19th, 2009
thanks again flamingclaw for your help, sorry havent marked thread as solved sooner, been away working.

Thanks quaifp1 too for your reply.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC