Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stop Non-numeric strings from crashing the server.
#17
I figured i didn't need to post the results for just a regular number because the results were about the same.
Quote:%Faster -12.5| -16.7| -28.6| -14.3| 20| -14.3| -14.3| 0| 0| -14.3
Test1 7| 5| 5| 6| 6| 6| 6| 6| 6| 6
Test2 8| 6| 7| 7| 5| 7| 7| 6| 6| 7

Code:
Public Sub TestOne()
    CCInt "222"
End Sub

Private Function CCInt(ByRef s As String) As Integer
    If LenB(s) = 0 Then Exit Function
    If Not s Like "*[!0-9]*" Then CCInt = CInt(s)
End Function

Code:
Public Sub TestTwo()
    CCInt "222"
End Sub

Private Function CCInt(ByRef s As String) As Integer
    If LenB(s) = 0 Then Exit Function
    If IsNumeric(s) Then CCInt = CInt(s)
End Function
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)