Board index » delphi » Case statement : How to check on edit.text in case statement

Case statement : How to check on edit.text in case statement

How do I check wether a edit-box has a certain string value

Quote
I wrote:

Case edit1.text of
'VM' : ...
'TE' : ...
'WE' : ...
.
.
.
else ...
I get an error message that the check must be of an ordinal type.
How can I solve this problem. I would appreciate any tips and
suggestions. Thanks
Tom... My e-mail is not Mascha.VanHouteghem this is the e-mail of a
friend of me. My e-mail is : 94021...@babbage.hogent.be.
 

Re:Case statement : How to check on edit.text in case statement


Quote
>   Mascha Van houteghem <Mascha.Vanhouteg...@rug.ac.be> writes:
>  How do I check wether a edit-box has a certain string value
>  I get an error message that the check must be of an ordinal type.
>  How can I solve this problem. I would appreciate any tips and

Depends on the situation. One way is to use multiple if constructions.

If the first letter of what the user can enter in your edit boxes is unique you could use
case ord(edit.text[1]) of

and then have the values for the ascii of the possible first character.

I have solved this with a constant containing the possible values:
monyear := 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'

and then used
case pos(edit1.text,monyear) of
1
5
9
12
etc

johan

Other Threads