Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 9 of 9 total |
From Edit.text to float |
Wed, Mar 19 2008 8:08 AM | Permanent Link |
Thor | Programming again.
I want to grab a value from a Edit.text and store it in a field (float) in a table. Now strToFloat(edit2.text) causes "Not a valid floating point value". Any suggestions? |
Wed, Mar 19 2008 8:46 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Thor
Try strToFloat(Trim(edit2.text)) Roy Lambert |
Wed, Mar 19 2008 9:02 AM | Permanent Link |
Thor | Roy Lambert <roy.lambert@skynet.co.uk> wrote:
Thor Try strToFloat(Trim(edit2.text)) Roy Lambert Roy, still among the helpful knigths!! Great! I have been off for a long while. Need an update. Sorry, trim made no difference here. I am a bit confused, since I had conversion going for a short while. Then errormessages took place, regardsless off restarting the pc. |
Wed, Mar 19 2008 9:51 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Thor
What's actually in the text you're trying to convert? Are you sure that it is a valid floating point number? Roy Lambert |
Wed, Mar 19 2008 11:47 AM | Permanent Link |
Thor | Roy Lambert <roy.lambert@skynet.co.uk> wrote:
Thor What's actually in the text you're trying to convert? Are you sure that it is a valid floating point number? Roy Lambert Roy, Actually, it is currency, mostly integers. This used to work fine .... Thor |
Wed, Mar 19 2008 2:05 PM | Permanent Link |
Tony Bryer | In article
<78FA1325-A365-4DB7-AD0A-67BC3333355A@news.elevatesoft.com>, Thor wrote: > I want to grab a value from a Edit.text and store it in a field > (float) in a table. Now strToFloat(edit2.text) causes "Not a > valid floating point value". Is this with your own data, or a report from a user. Note that StrToFloat (etc) use the separators defined in Windows Control Panel which may not be the same as yours. Also note that Delphi's Val function doesn't do this - it always assumes a period for the decimal separator. How do I know this .... don't ask -- Tony Bryer SDA UK 'Software to build on' http://www.sda.co.uk Shareware Industry Conference 2006 sponsor www.sic.org |
Thu, Mar 20 2008 3:30 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Thor
If Tony's point about the decimal separator isn't the problem can you post a sample of the data to the binaries. Roy Lambert |
Thu, Mar 20 2008 6:45 AM | Permanent Link |
Thor | Roy Lambert <roy.lambert@skynet.co.uk> wrote:
Thor If Tony's point about the decimal separator isn't the problem can you post a sample of the data to the binaries. Roy Lambert Thanks to Roy and Tony. Solved. I had 2 edits for converting and thougth I had initiated both to 0. But I was wrong. Leaving one of them emty (!) was no good for StrToFloat! Sorry for inconveniance. |
Tue, Apr 1 2008 1:11 PM | Permanent Link |
Rolf Frei eicom GmbH | One thing you should be aware too is, that StrToFloat doesn't respect the
thousand separator. So a Windows formated number larger than 1000 will also produce that error. So this StrToFloat('5,555.55') will raise an exception. For this reason I did write an own function to handle it: function MyStrToFloat(const S: String): Extended; begin try Result := StrToFloat(S); except Result := StrToFloat(StringReplace(S, ThousandSeparator, '', [rfReplaceAll])); end; end; Regards Rolf "Thor" <twarberg@online.no> schrieb im Newsbeitrag news:B6184960-A3FB-419E-B548-7B487A8E6C41@news.elevatesoft.com... > Roy Lambert <roy.lambert@skynet.co.uk> wrote: > > Thor > > > If Tony's point about the decimal separator isn't the problem can you post > a sample of the data to the binaries. > > Roy Lambert > > Thanks to Roy and Tony. > > Solved. I had 2 edits for converting and thougth I had initiated both to > 0. > But I was wrong. Leaving one of them emty (!) > was no good for StrToFloat! Sorry for inconveniance. > |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |