-
February 9th, 2010, 02:36 PM
#1
Problem with decimals
Hi!
I have a report that show prices, like $1.33
The problem is that it is not showing decimals correctly, it shows 1.33 like $1.00
I checked the field format, round rules, etc. Is not that.
I checked regional settings. Is not that either.
I checked dll (crystal) versions.
In db (access) the value is right. It´s a float type.
My locale is Brazil, so, decimal separator is "," and tousand separator is "."
(In the example above, i used dot as decimal separator just to explain).
I´m calling the report with vb6 (sp6). In Crystal Report (designer, 8.0.1.0) the price is correctly.
It just happens when the report is called from vb program, and not in all computers. Just a few.
Same EXE, same RPT and same DLL, but the problem occurs.
Code in vb6:
sql = "SELECT ... PRE_PEDIDO_ITEM.PPIT_VLR_UNIT, PRE_PEDIDO_ITEM.PPIT_VLR_LIQ, ... " & _
"FROM ... PRE_PEDIDO_ITEM, ... " & _
"WHERE ... "
Rpt.LogOnServer "p2sodbc.dll", "DRP2", "DRP2", "XXXXX", "XXXXX"
Rpt.WindowShowRefreshBtn = True
Rpt.WindowShowSearchBtn = 1
Rpt.WindowShowCloseBtn = 1
Rpt.WindowTitle = "Order"
Rpt.WindowState = crptMaximized
Rpt.SQLQuery = sql
Rpt.Action = 1
Any idea?
-
February 9th, 2010, 03:09 PM
#2
Re: Problem with decimals
Can't you use a Currency data type?
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
February 9th, 2010, 04:04 PM
#3
Re: Problem with decimals
It´s a legacy application that have been working for years.
This is a recent problem, so I don´t think that change the database column type
is the best solution. It´s a ruge impact.
tks.
-
February 9th, 2010, 08:27 PM
#4
Re: Problem with decimals
Well, what can we do, if it's NOT the code?
-
February 10th, 2010, 06:23 AM
#5
Re: Problem with decimals
Well, I thought that people in this forum could have face a problem like this.
I think it could be something like windows hotfix conflicting with this old crystal/vb...
and I was hoping that maybe you be experienced enough to help me, because right now,
i´m desperate.
I believe that this problem is less programming skill and more about experience/know how.
-
February 10th, 2010, 08:16 AM
#6
Re: Problem with decimals
Just because it used to work, doesn't mean that a change in coding can't fix it. In addition to the Currency data type, there is also the Format() function, which can return a number in the format of your choosing.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
February 10th, 2010, 10:51 AM
#7
[SOLVED] Re: Problem with decimals
I fixed it.
Before I call the report I change the regional settings by code using kernel32 api.
And change it back after the report is loaded.
Private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
Dim wInfo As Long
Dim Locale As Long
Locale = GetUserDefaultLCID()
wInfo = SetLocaleInfo(Locale, &H16, ".")
It still doesn´t explain why it was working in some computer and others not (they have the same regional settings configuration and same version off all software).
But... it´s working now.
Sometimes i think that computers is not a exact science as it should be 
tks.
-
February 10th, 2010, 11:57 AM
#8
Re: Problem with decimals
Well done.
But it IS an exact science. It is possibly the most exact science there is at all, being always reduced down to 0 and 1. 
However, it is possibly also a very complex and sometimes intransparent science. But always exact.
-
February 10th, 2010, 01:36 PM
#9
Re: Problem with decimals
There is a saying; The nice thing about computers is that they do exactly what you tell them to do. The bad thing about computers is that they do exactly what you tell them to do.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
February 12th, 2010, 10:16 AM
#10
Re: Problem with decimals
Right.
Last edited by WoF; February 12th, 2010 at 10:19 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|