Обсуждение: Numeric Type and VB/ODBC

Поиск
Список
Период
Сортировка

Numeric Type and VB/ODBC

От
"Bret"
Дата:
This may not be the right group, if so, just let me know.

I have a table with a type [numeric].

When executing queries, I get the data which happens to
be (6.5) in this case, but my VB6 function which traps
for nulls (below) returns a null.

If I change it to type [real]. No problems


Function IsNothing(varToTest As Variant) As Integer
'  Tests for a "logical" nothing based on data type
'  Empty and Null = Nothing
'  Number = 0 is Nothing
'  Zero length string is Nothing
'  Date/Time is never Nothing

    IsNothing = True

    Select Case VarType(varToTest)
        Case vbEmpty
            Exit Function
        Case vbNull
            Exit Function
        Case vbBoolean
            If varToTest Then IsNothing = False
        Case vbByte, vbInteger, vbLong, vbSingle, vbDouble, vbCurrency
            If varToTest <> 0 Then IsNothing = False
        Case vbDate
            IsNothing = False
        Case vbString
            If (Len(varToTest) <> 0 And varToTest <> " ") Then IsNothing =
False
    End Select

End Function


Bret Stern



Re: Numeric Type and VB/ODBC

От
Andrei
Дата:
You can try

If  (IsNumeric(varToTest) And 0 = CDbl(varToTest)) Then IsNothing = True

Bret wrote:
> This may not be the right group, if so, just let me know.
>
> I have a table with a type [numeric].
>
> When executing queries, I get the data which happens to
> be (6.5) in this case, but my VB6 function which traps
> for nulls (below) returns a null.
>
> If I change it to type [real]. No problems
>
>
> Function IsNothing(varToTest As Variant) As Integer
> '  Tests for a "logical" nothing based on data type
> '  Empty and Null = Nothing
> '  Number = 0 is Nothing
> '  Zero length string is Nothing
> '  Date/Time is never Nothing
>
>     IsNothing = True
>
>     Select Case VarType(varToTest)
>         Case vbEmpty
>             Exit Function
>         Case vbNull
>             Exit Function
>         Case vbBoolean
>             If varToTest Then IsNothing = False
>         Case vbByte, vbInteger, vbLong, vbSingle, vbDouble, vbCurrency
>             If varToTest <> 0 Then IsNothing = False
>         Case vbDate
>             IsNothing = False
>         Case vbString
>             If (Len(varToTest) <> 0 And varToTest <> " ") Then IsNothing =
> False
>     End Select
>
> End Function
>
>
> Bret Stern
>
>
>
>