+ Reply to Thread
Results 1 to 9 of 9

Force Format decimal to (.) regardless of regional settings

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Force Format decimal to (.) regardless of regional settings

    Hi all,

    i hope you can help.

    Due to different regional settings used, and especially the decimal (,) or (.), I have been making use of the code below to allow for the capture of (.) when the regional decimal is set to (,).

    But this obviously only allows me to capture using the (.), but then changes the (.) back to (,) based on the regional decimal settings.

    How can i force format my values captured throughout my UserForm to be (.)? I.e., when saving to excel, may decimal in my values will be (.), regardless of my regional settings.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Thank you!
    Sharing knowledge, can be likened to taking another person's hand, and pulling them up to a higher level -- onmyway

    If I was helpful, please remember to click on * Add Reputation below

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Force Format decimal to (.) regardless of regional settings

    This should solve your problem. Put in workbook open.

    Please Login or Register  to view this content.
    Please click the * below if this helps

  3. #3
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Force Format decimal to (.) regardless of regional settings

    Hi Jasper,

    Thank you for your response!

    It seems like a simple solution, but it does not seem to work.

    I put the code as follows:

    Please Login or Register  to view this content.
    But when I run a procedure as below (bottom), it triggers my error:

    Please Login or Register  to view this content.
    I.e., it does not see it as a numeric value.

    But, if my systems setting is set to use (.), it does not give this error. Also, if I use the method I used in my first post, I do get to put in either (.) or (,), but the decimal displays as the system decimal (,) and not (.) as per the Workbook_Open event.


    Please Login or Register  to view this content.
    Any ideas?

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Force Format decimal to (.) regardless of regional settings

    works for me...
    Obvious question - did you close and reopen the workbook?
    You could put it at the start of your code as well, but I advised to put it into workbook open to make sure you always run it.

    What dimension did you set for "txtHourMetersSOS1" ?
    Is it set as a number? or as a string? If it's set as a string, then it might not work.
    Perhaps:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Force Format decimal to (.) regardless of regional settings

    Yes, i did close and re-open a few time.

    I tried the code in my txtHourMetersSOS1_Enter event as well - does not work. Weird....

    i am not too sure I know what you mean with this:

    What dimension did you set for "txtHourMetersSOS1" ?
    Please Login or Register  to view this content.
    I also tried this suggestion:

    Please Login or Register  to view this content.
    But got an error on the part "/ 1" that replaced the .Value.

  6. #6
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Force Format decimal to (.) regardless of regional settings

    Your variable "txtHourMetersSOS1" is not set as a number.

    Where did you put your "dim txtHourMetersSOS1 as ...." ?

  7. #7
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Force Format decimal to (.) regardless of regional settings

    Ohhh!

    My txtHourMeterSOS is a simple textBox. The code used, is simply to format it in my desired format when one exits the field.

  8. #8
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Force Format decimal to (.) regardless of regional settings

    can you share a sample worksheet?
    Do you use a formcontrol or activex textbox?

  9. #9
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Force Format decimal to (.) regardless of regional settings

    Hi Jasper

    Will see what I can do tomorrow. I have had it for today. Thanks for all your help!

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Date format and regional settings
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2014, 03:22 AM
  2. Help required: VBA ignoring regional date settings - using US format as default.
    By Nukamoi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-29-2012, 02:24 PM
  3. Blocking regional settings?
    By The1nk in forum Excel General
    Replies: 0
    Last Post: 07-03-2008, 08:38 AM
  4. regional settings
    By gmoney10111 in forum Excel General
    Replies: 1
    Last Post: 05-06-2007, 12:27 PM
  5. Regional Settings
    By LAF in forum Excel General
    Replies: 2
    Last Post: 07-30-2005, 08:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1