I passed a numeric value of 1,000,000 to a sub and checked the length of it. This is what I got in the Immediate window.
It seems the effect of TRIM is short-lived. Somehow Excel appends a space after num right away. What's going on here? How do I prevent Excel from adding the trailing space?
Further test shows this:
There doesn't seem to be a trailing space (though it does have one in the Immediate window). So, why is the length 8, not 7?
VBA Code:
Sub income_RG(num As Double)
Debug.Print num <-gives 1000000 with a trailing space
num = Trim(num)
Debug.Print num <-gives 1000000 with a trailing space
Debug.Print Len(num) <- gives 8
Debug.Print Len(Trim(num)) <- gives 7
Debug.Print Len(num) <-give 8
......
It seems the effect of TRIM is short-lived. Somehow Excel appends a space after num right away. What's going on here? How do I prevent Excel from adding the trailing space?
Further test shows this:
VBA Code:
Debug.Print num&a <gives 1000000a
There doesn't seem to be a trailing space (though it does have one in the Immediate window). So, why is the length 8, not 7?