| View previous topic :: View next topic |
| Author |
Message |
Bill Todd (TeamB) Guest
|
Posted: Fri Jan 30, 2004 2:01 pm Post subject: Re: Numeric or String |
|
|
On Fri, 30 Jan 2004 11:25:21 -0300, "Luiz Fernando"
<lfernandosilva (AT) zipmail (DOT) com.br> wrote:
| Quote: | How Can I to know if a variable is numeric or string?
|
The obvious answer is, look at its declaration. What are you trying
to do? Your question is not clear.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Luiz Fernando Guest
|
Posted: Fri Jan 30, 2004 2:25 pm Post subject: Numeric or String |
|
|
Hi...
How Can I to know if a variable is numeric or string?
thanks
Luiz Fernando
|
|
| Back to top |
|
 |
Luiz Fernando Guest
|
Posted: Fri Jan 30, 2004 3:02 pm Post subject: Re: Numeric or String |
|
|
Sorry....
I'd like to know if an value of field database is numeric or string.
thanks
Luiz Fernando
"Bill Todd (TeamB)" <no (AT) no (DOT) com> escreveu na mensagem
news:krok105ljaln0roak6f39n0qm5fjlh87m7 (AT) 4ax (DOT) com...
| Quote: | On Fri, 30 Jan 2004 11:25:21 -0300, "Luiz Fernando"
[email]lfernandosilva (AT) zipmail (DOT) com.br[/email]> wrote:
How Can I to know if a variable is numeric or string?
The obvious answer is, look at its declaration. What are you trying
to do? Your question is not clear.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Dell Stinnett Guest
|
Posted: Fri Jan 30, 2004 3:49 pm Post subject: Re: Numeric or String |
|
|
| Quote: | I'd like to know if an value of field database is numeric or string.
|
Look at the DataType of the field -
If MyTable.FieldByName('SomeField').DataType = ftString then
//do whatever
else if MyTable.FieldByName('SomeField').DataType = ftInteger then
// do somthing else
If you need to do this prior to opening the table, use the FieldDefs
property:
MyTable.FieldDefs.Update; //get the field definitions from the table
If
MyTable.FieldDefs.Items[MyTable.FieldDefs.IndexOf('SomeField')].DataType =
ftString then...
-Dell
|
|
| Back to top |
|
 |
Andrew Guest
|
Posted: Fri Jan 30, 2004 8:06 pm Post subject: Re: Numeric or String |
|
|
try this
function isInteger(s : String) : boolean;
var
dummyInt : Integer;
begin
result := true;
try
dummyInt := StrToInt(s);
except
result := false;
end;
end;
function isNumeric(s : String) : boolean;
var
dummyNo : double;
begin
result := true;
try
dummyNo := StrTofloat(s);
except
result := false;
end;
end;
On Fri, 30 Jan 2004 11:25:21 -0300, "Luiz Fernando"
<lfernandosilva (AT) zipmail (DOT) com.br> wrote:
| Quote: | Hi...
How Can I to know if a variable is numeric or string?
thanks
Luiz Fernando
|
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Fri Jan 30, 2004 10:26 pm Post subject: Re: Numeric or String |
|
|
if youDataset.FieldByName('..') is TNumericField then
<this is a numeric>
else
<string or another data type>
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Luiz Fernando" <lfernandosilva (AT) zipmail (DOT) com.br> wrote
| Quote: | Sorry....
I'd like to know if an value of field database is numeric or string.
thanks
Luiz Fernando
"Bill Todd (TeamB)" <no (AT) no (DOT) com> escreveu na mensagem
news:krok105ljaln0roak6f39n0qm5fjlh87m7 (AT) 4ax (DOT) com...
On Fri, 30 Jan 2004 11:25:21 -0300, "Luiz Fernando"
[email]lfernandosilva (AT) zipmail (DOT) com.br[/email]> wrote:
How Can I to know if a variable is numeric or string?
The obvious answer is, look at its declaration. What are you trying
to do? Your question is not clear.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
|