Is there any IsDouble() function in VB6? If I'm not mistaken, Double data type in VB6 is equivalent to float in SQL Server 2000. Your advice would be much appreciated.
There's an IsNumeric()
function that should work well enough. If that is inadequate for your needs can you also explain in what ways?
Function IsDouble(ByVal varValue As Variant) As Boolean
Dim dblTest As Double
On Error Resume Next
dblTest = CDbl(varValue)
IsDouble = Err.Number = 0
End Function
IsNumeric() is fine, it will only accept values that fit into Doubles. It is regionally aware, i.e. for French regional settings the decimal separator is a comma.
I just tried this in the Immediate window.
Debug.Print IsNumeric("4e308")
False
The definition of a VB6 Double in the manual is "VB6 Double variables are stored as IEEE 64-bit (8-byte) floating-point numbers ranging in value from -1.79769313486232E308 to -4.94065645841247E-324 for negative values and from 4.94065645841247E-324 to 1.79769313486232E308 for positive values".
I think that's the same as a SQL Server float, going by the online docs. "Floating precision number data with the following valid values: -1.79E + 308 through -2.23E - 308, 0 and 2.23E + 308 through 1.79E + 308."
Actually your much better off using the Vartype function.
Private Function IsDouble(ByVal value As Variant) As Boolean
IsDouble = (VarType(value) = vbDouble)
End Function
Kind Regards Noel