+ Reply to Thread
Results 1 to 5 of 5

Text box to allow 2 decimal

  1. #1
    Forum Contributor
    Join Date
    03-14-2015
    Location
    Mexico
    MS-Off Ver
    365
    Posts
    279

    Text box to allow 2 decimal

    Hi Folks,

    I am trying to limit my Textbox to these numbers 22.45, 10.45 etc. This is my code. It is giving me the 2 decimals por only allowing me to put 1 number before the dot e.g. 2.45, 1.45 etc. Any idea?

    TextBox2.Value = Format(TextBox2.Value, "##.##")

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Text box to allow 2 decimal

    That format will retain any number of digits to the left of the dot. Give a specific example of a number you enter and the result you get.

    You might also try this:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    03-14-2015
    Location
    Mexico
    MS-Off Ver
    365
    Posts
    279

    Re: Text box to allow 2 decimal

    Thank you. I want to enter 22.45 but when entering the 22 it only allows me to put one "2" after this the dot comes up and it lets me to put the decimals "45". As a result I only get 2.45 instead of the 22.45

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Text box to allow 2 decimal

    Ah, incomplete information. Is your line of code in Sub TextBox2_Change? If so, then this is the wrong approach for what you want to do.

    There is no need to force this format as you go. Move your line of code to the place in your code where you actually use the value, such as the click of a button. This gives the user the chance to enter the entire number before you reformat it.

  5. #5
    Forum Contributor
    Join Date
    03-14-2015
    Location
    Mexico
    MS-Off Ver
    365
    Posts
    279

    Re: Text box to allow 2 decimal

    Thank you! It worked.

+ 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. [SOLVED] multiple decimal number and text.
    By Neikichi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-17-2016, 05:26 PM
  2. VBA to convert decimal time to text
    By ciresuark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2016, 02:10 PM
  3. Text and number in a cell with no decimal
    By 2001jesper in forum Excel General
    Replies: 2
    Last Post: 02-05-2014, 10:33 AM
  4. Convert decimal text into hh:mm:ss
    By k_doe in forum Excel General
    Replies: 4
    Last Post: 03-22-2010, 05:27 PM
  5. Display Decimal value in text box ?
    By Breizh29 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2010, 05:52 AM
  6. Treat Decimal Value in Text Box
    By Breizh29 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2010, 09:22 PM
  7. [SOLVED] Fixed Decimal in Text Box
    By Donald in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-07-2005, 05:06 PM

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