I want to know what kind of decimal separator is being used in a CPU from a VB6 routine.
How can I do this?
My best regards
José Nogueira
Printable View
I want to know what kind of decimal separator is being used in a CPU from a VB6 routine.
How can I do this?
My best regards
José Nogueira
I suppose the first question I should ask is "Why?"
What difference does it make how the calculation is processed in the CPU providing the figures it comes up with are correct..?
At the lowest level it's only voltage changes in a wire anyway..!!
I'm sure you don't mean CPU. The CPU does not use decimal seperators, it uses floating point maths, and it is not in decimal format at all.
Only when the operating system receives the results does decimal format become relevant. The operating system will display the result with the decimal seperator of the users choice. In the case of the Windows operating system, this choice is set in the regional settings. You have to read the regional settings for the specific user to determine what the seperator is.
Shrog
The decimal seperator is stored in the registry on NT..
HKEY_CURRENT_USER\Control Panel\International\sDecimal
and on 98/95 you can get it from the file win.ini..
[intl]
sDecimal=.
BTW, whats the usual sDecimal you have since i have:
sDecimal=,
i've always had that and it's kind of disturbing when you get commas as results of vb calculations and have to enter points.
UK seetings, sDecimal=.
I think everywere else uses a comma :(
South Africa Setting: sDecimal=.
Africa Rules!
Shrog
damn, maybe i have to change..
Yep guys, here in Holland we have the comma too!
But I just want to say it sucks that the UK wants to do every not-standard (plugs, screws, driving left, weights, mesurements, not even the Euro?! (oh.. am I right?))
I think we have to ban the UK from europe as long as they don't comply with 'the' standards :)
hehe just kidding, but it can be quite annoying when you want to use your discman in london and the plug doesn't fit!?!
And if they say you can buy 1 foot of licorice I don't even know how long it is!
And when I want to know how big my monitor is, I want to hear it in CM! not Inches :D
hehe ok I'm overacting.
sDecimal=,
Here in Sweden !
hehe cool, maybe i change back to , since the majority have ","'s now :)
Hello,
I would like to change the value
HKEY_CURRENT_USER\Control Panel\International\sDecimal
","--> "."
I work in VB6
It´s possible ?
Mauricio
When I had an installation in Montreal, I had some problems with exports from VB6 to Excel, and the way things were processed. It turned out they were using a comma (rather than a period) for the decimal separator, and that was causing all the problem.
To fix it, I wrote the following:
As a caveat, this changes it for the WHOLE SYSTEM, and not just this program that changes it. For my client, that was fine. However, it may not be fine in other situations.Code:
Option Explicit
Private Declare Function GetLocaleInfoA Lib "kernel32" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Declare Function SetLocaleInfoA Lib "kernel32" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Long
Private Sub ForceSystemDecimalToPeriod()
' We MUST use the ANSI API version so it's an ANSI character that's used for the actual decimal character.
Const LOCALE_SDECIMAL As Long = &HE&
Const LOCALE_SGROUPING As Long = &H10&
Const Eng_LCID As Long = 1033&
Dim s As String
'
s = String$(GetLocaleInfoA(Eng_LCID, LOCALE_SDECIMAL, vbNullString, 0&), 0)
GetLocaleInfoA Eng_LCID, LOCALE_SDECIMAL, s, Len(s)
If RTrimNull(s) <> "." Then
SetLocaleInfoA Eng_LCID, LOCALE_SDECIMAL, "."
SetLocaleInfoA Eng_LCID, LOCALE_SGROUPING, ","
End If
End Sub
Private Function RTrimNull(s As String) As String
RTrimNull = s
Do
If Right$(RTrimNull, 1&) <> vbNullChar Then Exit Do
RTrimNull = Left$(RTrimNull, Len(RTrimNull) - 1&)
Loop
End Function
If you really wanted to get fancy, you could check when your program has the system focus, and activate/deactivate it based on that. But that would require a bit of subclassing in VB6. In the CodeBank, I've got code to detect when a VB6 program gets/loses the system-wide focus.
Thanks you..
Separador Decimal ="." = OK
NOW
Símbolo de agrupamento de dígitos = ??
If you look at my code, you'll see the grouping character is already handled. :cool:
Hello,
Sorry, but Símbolo de agrupamento de dígitos = ?? doesn´t work
I try to put ".", but nothing
Mauricio
Why do you need the change the local settings of a user?
Our software is used in countries with all kind locale settings and we don’t have any problems
For anyone reading (in the future), LOCALE_SGROUPING is for something else.
The needed for thousand separator is:
Code:Const LOCALE_STHOUSAND As Long = &HF&
This is the "empirical" solution suggested by Francesco Balena.Code:Dim DcSp as long
DcSp = AscW(MidB$(1 / 2, 3, 2)) 'Contains the ASCII value of the decimal separator
If comma is your decimal separator then what happens when you create a CSV file containing numbers?