CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    About decimal point....

    I have a text box where the user enters a number. Specifically the number must be between 2,45 and 2,80. I control the keys pressed so that the user can only enter numbers, comma character and backspace ofcourse. I don't allow to press "."
    But what happens when the user has set to his own PC as decimal point the "." ? How can I check this with code. Or what else can I do?

    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department
    Athens, Greece

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: About decimal point....

    chris Eastwood has pulished an article that describes how to get access to the locale settings:
    http://codeguru.developer.com/vb/articles/1716.shtml
    It's the source code for an activex dll.


  3. #3
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    And what's next?

    So lets say that I use a piece of code of the whole project in order to find out which is the decimal separator on current pc. What comes next? What to do with my text box? Your suggestions?
    I must allow each user to press in the specific text box, the decimal point that have selected. How to do that as it differs from user to user?
    In order to be much helpful, I give you the code I use till now, pls add there your suggestions (code).


    private Sub txtGravity_KeyPress(KeyAscii as Integer)
    If KeyAscii = 8 Or KeyAscii = 44 then
    Exit Sub
    End If
    If KeyAscii < 48 Or KeyAscii > 57 then
    Beep
    KeyAscii = 0
    End If
    End Sub




    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department
    Athens, Greece

  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: And what's next?

    in the Form_Load event I'd call GetLocaleInfo API with LOCALE_SDECIMAL constant to get the chosen decimal separator.
    sub Form_Load
    dim sDecimal as string
    GetLocaleInfo...sDecimal

    Then in your keypress-Event:

    select case keyascii
    case 8, 44, asc(sDecimal)
    exit sub
    ...



    (this is pcode only!)


  5. #5
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Ok, on the way to try your suggestion...

    Well, I can easily see that it is pcode (as you say that). Not so stupid, thanx God!
    Well thanx a lot, I'll try it. Rating will be tomorrow, because it's late now... ;-) Thanx Lothar and thanx Chris of course for his article...

    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department
    Athens, Greece

  6. #6
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Thanx...

    ...Lothar!!!

    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department
    Athens, Greece

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

Featured