Quote Originally Posted by mrmmickle1 View Post
Code:
Val("1234.5.56Excel")
I am new to vba and i have been looking at some string items today. Regarding the above code I have a question.... Why does this code only return:

1234.5?

If this is to return numbers why would it not return

1234.5.56?

Is it because the 56Excel is alphanumeric? Does Val() not recognize numbers that are alphanumeric?
Val returns the leading number from a text string... it stops looking at the first character that no longer can be used to form a real number. Since numbers can only have one decimal point, it rejects the second decimal point because it cannot be used to form a real number, so Val returns everything before that invalid numeric character.