Search code examples
vbacatia

Storing 001 instead of 1 in variables in VBA


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.


Solution

  • 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