08-04-2009, 05:40 PM
I would make the function more like this
* Edit
I changed it a little bit.
I was testing a little bit more..
If you have a string like "2add2", and use Val(string) it will = 2. With the above method it will equal 0.
Code:
Public Function CCInt(ByRef s As String) As Integer
If Len(s) = 0 Then Exit Function
If Not s Like "*[!0-9]*" Then CCInt = CInt(s)
End Function
* Edit
I changed it a little bit.
I was testing a little bit more..
If you have a string like "2add2", and use Val(string) it will = 2. With the above method it will equal 0.