Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stop Non-numeric strings from crashing the server.
#6
I would make the function more like this
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.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)