Re: Datatype checking in DotNET



You can use a function called StrToFloat (There is other variations of this function also ie. StrToFloatF)
"Nicholas Sherlock" <N.sherlock@xxxxxxxxx> wrote in message news:f62ggo$i9o$1@xxxxxxxxxxxxxxxxxx
I've never seen DotNet, but there is probably some method of a Double class, for instance, that attempts a conversion from a string to a double and will throw an error or give a return code if the string isn't a valid double.

Hi Nicholas,

Hi Nicholas,

Yeah I am doing that now at the moment for example as based on the given example previously:-

I use StrToFloat, if this fails, it raises an exception (Which is fine of course).

But what I am trying to achieve here is to ensure the data integrity, does the data meet the float bounds?????

For integers you could do a test like this:-

tempVal := StrToInt (fieldStr);
if (tempVal < low (IntImSavingToo )) or (tempVal > high (IntImSavingToo )) then
exit;
IntImSavingToo := tempVal;

Is there something I can use for floats, doubles and singles also???

Daniel.

.



Relevant Pages

  • Re: FPU Control World
    ... I have never, yet, found a problem with Delphi's StrToFloat. ... "float" storage and calculations. ...
    (borland.public.delphi.language.basm)
  • Re: Datatype checking in DotNET
    ... Yeah I am doing that now at the moment for example as based on the given ... But what I am trying to achieve here is to ensure the data integrity, ... StrToFloat will almost certainly do that too. ... Give it a try with a really big float, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Datatype checking in DotNET
    ... I use StrToFloat, if this fails, it raises an exception (Which is fine of ... But what I am trying to achieve here is to ensure the data integrity, does the data meet the float bounds????? ... StrToFloat will almost certainly do that too. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Datatype checking in DotNET
    ... Yeah I am doing that now at the moment for example as based on the given ... But what I am trying to achieve here is to ensure the data integrity, ... the data meet the float bounds????? ... (IntImSavingToo)) ...
    (comp.lang.pascal.delphi.misc)