Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF statement help 2

Status
Not open for further replies.

guava65

Programmer
Jul 20, 2001
238
US
I am writing a program and stumbled when I tried to use "or" in an if statement

Here's what I've got:
[tt]
Procedure TfBankRes.BtnCloseClick(Sender: TObject);
Begin
if tbBank.State = dsInsert or dsEdit then
begin
do some stuff;
end;
End;
[/tt]

I wanted to perform the same set of commands for both data states without having to create two seperate IF statements. I'm sure this is pretty basic just that I've never done it before.

Can anyone help.
Aloha,
cg
 
Unfortunately you can't do it that easily. Here is what you need:
Code:
Procedure TfBankRes.BtnCloseClick(Sender: TObject);
Begin
  if (tbBank.State = dsInsert) or (tbBank.State = dsEdit) then
   begin
    do some stuff;
   end;
End;
 
Thanks Zathras,

I didn't think of encapsulating each statement in parenthesis.
Aloha,
cg
 
or this...

[tt]
Procedure TfBankRes.BtnCloseClick(Sender: TObject);
Begin
if ( tbBank.State in [ dsInsert, dsEdit ] ) then
begin
do some stuff;
end;
End;
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top