Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 16 total
Thread Float is read as Integer ??
Tue, Dec 30 2008 12:39 PMPermanent Link

Noel Marshall
Hi,
I am a bit new to Delphi and DbiSam.

All of a sudden when I read Float values from a dbisam table (type Float in table) I keep
getting a result of an Integer (rounded up).
I tried all kind of format strings on this value but it's no use.
Can anyone please help me?
Thanks
Tue, Dec 30 2008 12:44 PMPermanent Link

"Eduardo [HPro]"
Noel

> All of a sudden when I read Float values from a dbisam table (type Float
> in table) I keep
> getting a result of an Integer (rounded up).
> I tried all kind of format strings on this value but it's no use.
> Can anyone please help me?

Could you post a piece of code here ? It will help us to help you.

But
If you have a float field you should read it using
YourTable.FieldByname('YourField').AsFloat

or you should define YourField as a Float persistent field.

Eduardo

Thu, Jan 1 2009 5:06 AMPermanent Link

Noel Marshall
Hi Eduardo,

thank you for your answer.

There is no code to post really.

I am reading the field in as you wrote it:
YourTable.FieldByname('YourField').AsFloat but to see what is reading I am encapsulating
it in:
ShowMessage(StrToFloat(YourTable.FieldByname('YourField').AsFloat));
And if for example, the value in this field is: 0.87 it will display 1

I tried using the formatstr, formatcurrency as well with no change Frown

thanks again
Thu, Jan 1 2009 5:09 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Noel


What do you get if you use ShowMessage(YourTable.FieldByname('YourField').AsString) ?

Roy Lambert [Team Elevate]
Thu, Jan 1 2009 11:13 AMPermanent Link

Noel Marshall
Hi Roy,
If I try: ShowMessage(YourTable.FieldByname('YourField').AsString)
It will show a stored value of 0.93 also as 1!

I have tried changing the field type in the table itself from Float to Currency with no
difference!

The only difference was that when it was set to Currency the value showed up as  €0.93 and
when I change it to a type of Float it changes to 0.9345....naturally while browsing the
table from dbsys

regards


Roy Lambert <roy.lambert@skynet.co.uk> wrote:

Noel


What do you get if you use ShowMessage(YourTable.FieldByname('YourField').AsString) ?

Roy Lambert [Team Elevate]
Thu, Jan 1 2009 12:03 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Noel


Which version of Delphi, DBISAM & Windows?

Can you also post a small test project (source and .exe) to the binaries.

Roy Lambert [Team Elevate]
Fri, Jan 2 2009 1:33 AMPermanent Link

Noel Marshall
hmmmm....do you think it might be Vista that's causing this??

It is the first time I am using Delphi under Vista!!  Frown
Fri, Jan 2 2009 3:09 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Noel


I'm doubtful - I use D6 and D2006 under Vista and its not a problem I've encountered.

Roy Lambert [Team Elevate]
Fri, Jan 2 2009 1:07 PMPermanent Link

"Malcolm"
Noel Marshall wrote:

> hmmmm....do you think it might be Vista that's causing this??
>

I don't think so either.  
You have established that the correct value is stored so it sounds to
me more like a persistent field with the wrong display format -
though I don't know if that would actually give the observed effect.
I once spent a long time failing to get a desired format .. until ..

Malcolm

--
Sun, Jan 4 2009 2:52 AMPermanent Link

Noel Marshall
I feel I am going crazy.
Started a new barebone project but used the sam table and a simple dbgrid.
Values in table look float!! Frown

In my main app, dropped another table, datasource & dbgrid components and attached to same
table, values are integers again! Frown
In same app, did the above BUT with another table and values appeared float.

I am going to hit my monitor! Smile

regards
Page 1 of 2Next Page »
Jump to Page:  1 2
Image