10-04-2009, 01:49 PM
I was just thinking, if you want to be truely protected with these conversions, you'll also need to check for overflows.
[code]Private Function CCByte(ByRef s As String) As Byte
' Make sure there is a valid string
If LenB(s) = 0 Then Exit Function
' Check if it's a number
If Not s Like "*[!0-9]*" Then
' Check for overflows
If s >= 0 Then
If s = -32768 Then
If s = -2147483468 Then
If s
[code]Private Function CCByte(ByRef s As String) As Byte
' Make sure there is a valid string
If LenB(s) = 0 Then Exit Function
' Check if it's a number
If Not s Like "*[!0-9]*" Then
' Check for overflows
If s >= 0 Then
If s = -32768 Then
If s = -2147483468 Then
If s