+ Reply to Thread
Results 1 to 8 of 8

Command to omit first number not the best choice?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Command to omit first number not the best choice?

    Hi ,

    I recently has some code whereby a TextBox would display a number without the first digit. So, 3.456 would be displayed as .456 which allowed the textBox to make a certain calculation.
    However, sometimes the number 12.214 would be displayed and of course I need .214 but the TextBox is displaying 2.214. So I need code that will display any number including and after the decimal point?

    Can anyone help as to how this line can be adapted?

    TextBox8.Value = Right(TextBox5.Value, WorksheetFunction.Max(Len(TextBox5.Value) - 1, 0)) 'THIS DISPLAYS THE FIGURE WITHOUT THE FIRST FIGURE e.g. .25454
    Many Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Command to omit first number not the best choice?

    Hi,

    Untested but perhaps simply

    TextBox8.Value = Texbox5.Value - Int(Textbox5).Value
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Command to omit first number not the best choice?

    Got a Syntax error?
    Attached Images Attached Images

  4. #4
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Command to omit first number not the best choice?

    Thanks, I'll give it a go Cheers

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Command to omit first number not the best choice?

    There's a misplaced bracket, but (as in the code in your image), you should use the VAL() function to ensure you are working with real values

    TextBox1.Value = Val(TextBox1.Value) - Int(Val(TextBox1.Value))  '// Or whatever textbox number it is

  6. #6
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Command to omit first number not the best choice?

    I've put this but got crazy values?

    Old code gives me 0.569 (which is correct) but the code:


    TextBox1.Value = Val(TextBox1.Value) - Int(Val(TextBox1.Value))
    gives me -36.431?

    Ideally, I'd like the code to take a number from the decimal point onwards. That was it won't matter how many digits are before the decimal point because the code will ignore them all.For example, the figure 123.456
    will be .456, if the figure is 12.456 it will still be .456 and if the figure is 3.456 it will still be .456.

    ??

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Command to omit first number not the best choice?

    Did you note the comment about "whatever Textbox number it is"???

  8. #8
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Command to omit first number not the best choice?

    Sorry, it does work fine, I missed the last Text Box:

    TextBox8.Value = Val(TextBox5.Value) - Int(Val(TextBox1.Value))
    Thank you very much ;-)

+ 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. Multiple Time Stamps depending on choice in Drop Down List Choice
    By insayah in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-25-2022, 09:53 AM
  2. Replies: 3
    Last Post: 12-09-2013, 04:21 AM
  3. Replies: 5
    Last Post: 04-02-2013, 02:25 PM
  4. Replies: 2
    Last Post: 07-10-2012, 04:37 PM
  5. Replies: 2
    Last Post: 05-08-2012, 02:44 AM
  6. Omit cells based on variable row number
    By Steffen_DK in forum Excel General
    Replies: 5
    Last Post: 02-07-2012, 06:46 PM
  7. omit a negative number
    By LD6892 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-10-2006, 10:10 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