0

So this is the problem. I have a number 000.045678 I have split it using split method and stored it in 2 variables A and B. Now the value of A is 0 and B is 45678 But the need is A = 000 and B = 045678

How can this be done? Thankyou for the help in advance.

braX
  • 11,506
  • 5
  • 20
  • 33
  • Consider converting the numeric value into a string, then splitting the string at the decimal separator, then formatting each part accordingly, e.g. `Format(part1, "000")` or `Format(part2, "000000")`. Numbers don't have trailing or leading zeroes; it's strings you're looking for. – Mathieu Guindon Feb 08 '22 at 13:38

1 Answers1

1

when splitting a string containing 000.045678, you get the expected result

Dim inputString As String: inputString = "000.045678"
Dim SplitArray
SplitArray = Split(inputString, ".")
Dim A, B As String
A = SplitArray(0)
B = SplitArray(1)
Debug.Print A & "        " & B
Florent Cauwe
  • 76
  • 1
  • 4