How to abstract a number from a string?

  • Thread starter Thread starter Danny Hoon
  • Start date Start date
D

Danny Hoon

Hi all,

I'm trying abstract second number from a cell.
If cell a1=1234, how do I abstract 2 using a function?
I will need to use 2 for some math calculation.

I tried this but it don't work.

Function test(num As String)
test = num.char(1)
End Function

Thank for assisting.
 
Function test(num As String) as long
test = mid(num,2,1)
End Function

(with no validity checks at all!)
 
Thanks Dave!!!
Care to explain this line?
Function test(num As String) as long <== you are casting the String to a
Long data type?
 
Yep.

You said that it would be used for further math calculations.

Danny said:
Thanks Dave!!!
Care to explain this line?
Function test(num As String) as long <== you are casting the String to a
Long data type?
 
Back
Top