Results 1 to 21 of 21

Thread: Decimal separator with VB6

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    PORTUGAL
    Posts
    18
    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
    Eng. José Nogueira
    Mail: [email protected]
    Web: planeta.clix.pt/janogueira
    Entroncamento-Santarém-PORTUGAL

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    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..!!
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186

    Operating System

    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

  4. #4
    Lively Member
    Join Date
    Sep 1999
    Location
    Liverpool, UK
    Posts
    64
    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=.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Lively Member
    Join Date
    Sep 1999
    Location
    Liverpool, UK
    Posts
    64
    UK seetings, sDecimal=.

    I think everywere else uses a comma

  7. #7
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186

    Cool .

    South Africa Setting: sDecimal=.

    Africa Rules!


    Shrog


  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Unhappy

    damn, maybe i have to change..
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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

    hehe ok I'm overacting.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  10. #10
    Lively Member
    Join Date
    Jul 1999
    Posts
    87

    Thumbs up

    sDecimal=,

    Here in Sweden !

    Thank you, Jerry.

    Homepage: http://fraxionsoftware.cjb.net
    ICQ: 40269591
    Mail: Contact Me

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    hehe cool, maybe i change back to , since the majority have ","'s now
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    New Member
    Join Date
    Aug 2024
    Posts
    3

    Re: Decimal separator with VB6

    Hello,
    I would like to change the value

    HKEY_CURRENT_USER\Control Panel\International\sDecimal

    ","--> "."

    I work in VB6
    It´s possible ?

    Mauricio

  13. #13
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,914

    Re: Decimal separator with VB6

    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:

    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
    
    
    
    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.

    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.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  14. #14
    New Member
    Join Date
    Aug 2024
    Posts
    3

    Re: Decimal separator with VB6

    Thanks you..

    Separador Decimal ="." = OK

    NOW
    Símbolo de agrupamento de dígitos = ??

  15. #15
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,914

    Re: Decimal separator with VB6

    If you look at my code, you'll see the grouping character is already handled.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  16. #16
    New Member
    Join Date
    Aug 2024
    Posts
    3

    Re: Decimal separator with VB6

    Hello,
    Sorry, but Símbolo de agrupamento de dígitos = ?? doesn´t work

    I try to put ".", but nothing


    Mauricio

  17. #17
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,742

    Re: Decimal separator with VB6

    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

  18. #18
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,687

    Re: Decimal separator with VB6

    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&

  19. #19
    Addicted Member
    Join Date
    Nov 2016
    Location
    Italy
    Posts
    235

    Re: Decimal separator with VB6

    Code:
    Dim DcSp as long
    DcSp = AscW(MidB$(1 / 2, 3, 2)) 'Contains the ASCII value of the decimal separator
    This is the "empirical" solution suggested by Francesco Balena.

  20. #20
    Addicted Member
    Join Date
    Jan 2009
    Location
    Mn-USA
    Posts
    168

    Re: Decimal separator with VB6

    If comma is your decimal separator then what happens when you create a CSV file containing numbers?

  21. #21
    Hyperactive Member gilman's Avatar
    Join Date
    Jan 2017
    Location
    Bilbao
    Posts
    273

    Re: Decimal separator with VB6

    Quote Originally Posted by VB-only View Post
    If comma is your decimal separator then what happens when you create a CSV file containing numbers?
    In this case, the field separator is ";"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width