Board index » delphi » using field value in case statement

using field value in case statement


2005-06-22 11:34:32 PM
delphi162
I have a data field one character in length whose values are alphabetic.
I would like to extract that value and use it in a case
statement. If I get it as a variant
vmyfieldvalue := fieldbyname('name').value;
how can I get this value into a char?
or, is there a better way?
Thanks
 
 

Re:using field value in case statement

One way is:
var
S: String;
C: Char;
begin
S := SomeQuery.FieldByName('SomeField').AsString;
C := S[1];
--
Bill Todd (TeamB)
 

Re:using field value in case statement

"Bill Todd" <XXXX@XXXXX.COM>writes
Quote
One way is:

var
S: String;
C: Char;
begin
S := SomeQuery.FieldByName('SomeField').AsString;
C := S[1];
Wouldn't this be safer?
var
S: String;
C: Char;
begin
S := SomeQuery.FieldByName('SomeField').AsString + ' '; // add one space
C := S[1];
- David Harper
 

Re:using field value in case statement

Quote
>var S: String; C: Char;
>begin
>S := SomeQuery.FieldByName('SomeField').AsString;
>C := S[1];
Wouldn't this be safer?
S := SomeQuery.FieldByName('SomeField').AsString + ' '; // add one
space
C := S[1];
Or even
S := SomeQuery.FieldByName('SomeField').AsString;
If (S <>'')
then C := S[1]
else C := #0;