BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Numeric or String

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Bill Todd (TeamB)
Guest





PostPosted: Fri Jan 30, 2004 2:01 pm    Post subject: Re: Numeric or String Reply with quote



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. Smile 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





PostPosted: Fri Jan 30, 2004 2:25 pm    Post subject: Numeric or String Reply with quote



Hi...

How Can I to know if a variable is numeric or string?

thanks

Luiz Fernando


Back to top
Luiz Fernando
Guest





PostPosted: Fri Jan 30, 2004 3:02 pm    Post subject: Re: Numeric or String Reply with 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...
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. Smile 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





PostPosted: Fri Jan 30, 2004 3:49 pm    Post subject: Re: Numeric or String Reply with quote

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





PostPosted: Fri Jan 30, 2004 8:06 pm    Post subject: Re: Numeric or String Reply with quote

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





PostPosted: Fri Jan 30, 2004 10:26 pm    Post subject: Re: Numeric or String Reply with quote

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. Smile What are you trying
to do? Your question is not clear.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.