Home > Archive > Visual Basic > March 2006 > VB6 question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Mike P 2006-03-29, 3:56 am |
| If you are reading a field from a database in a loop and then adding the
value in the field to a variable, how do you test that the value is not
null before adding it? This code gives a type mismatch error :
if rs("FixedGP") <> "" then
Total_Total_F = CLng(Total_Total_F) + CLng(rs("FixedGP"))
end if
Thanks,
Mike
*** Sent via Developersdex http://www.developersdex.com ***
| |
| NickHK 2006-03-29, 3:56 am |
| Mike,
if not isnull(rs("FixedGP")) then.....
But Null is not the same as "", so you should check that also, otherwise you
CLng will fail.
Also, presumably Total_Total_F is already Dimmed as a numeric type, so
CLng(Total_Total_F) achieves nothing.
NickHK
"Mike P" <mike.parr@gmail.com> wrote in message
news:Osi%23o3wUGHA.5500@TK2MSFTNGP12.phx.gbl...
> If you are reading a field from a database in a loop and then adding the
> value in the field to a variable, how do you test that the value is not
> null before adding it? This code gives a type mismatch error :
>
> if rs("FixedGP") <> "" then
> Total_Total_F = CLng(Total_Total_F) + CLng(rs("FixedGP"))
> end if
>
> Thanks,
>
> Mike
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
| |
| Bob O`Bob 2006-03-31, 3:55 am |
| Mike P wrote:
> If you are reading a field from a database in a loop and then adding the
> value in the field to a variable, how do you test that the value is not
> null before adding it? This code gives a type mismatch error :
>
> if rs("FixedGP") <> "" then
> Total_Total_F = CLng(Total_Total_F) + CLng(rs("FixedGP"))
> end if
Total_Total_F = CLng(Total_Total_F) + CLng(rs("FixedGP") + 0)
Bob
|
|
|
|
|