0

I am trying to extract all numbers before the last non zero digits.

Examples:

  1. if I have a number 4210014000000000 i am trying to extract only 4210014.
  2. and if I have a number 621788000000000 i am trying to extract only 621788.
  3. and if I have just 232322 then it should be 232322.
kwoxer
  • 3,734
  • 4
  • 40
  • 70
Maine
  • 27
  • 5
  • Are these strings or numbers and what have you tried so far? – MatSnow May 13 '20 at 13:30
  • 4
    Assuming those *numbers* are strings, `[Number].TrimEnd('0')`. You should post the code you tried so far, so it's more clear what your dealing with (and you're also *on topic* :). – Jimi May 13 '20 at 13:30
  • Hello, Jimi.... sorry about the flag . that was a mistake. i was trying to mark your comment as a solution instead. it worked very fine . thanks a lot. – Maine May 13 '20 at 13:42

1 Answers1

0

Here is a function that extracts all numbers before the last non zero digit. You could also convert this into a String extension as well.

Public Function NumbersBeforeLastNonZeroDigit(ByVal sValue As String) As String
    Return sValue.TrimEnd("0")
End Function
ThePeter
  • 883
  • 1
  • 7
  • 15