VB2005 version of Access "NZ" function
Posted on 2010-11-17
I have a form that loads existing revenue records into text boxes. It tracks 24 months of revenue, so there are 24 boxes (all of this year and next year by month.) Virtually all of the records have some months with zero revenue.
Since the numeric revenue values are displayed as text in the boxes, calculations involving the text values must first convert the text to a number (I'm using Cdbl). It works for the non-zero values but throws an error for the zero values, which come out as "".
I can probably deal with this problem either by creating a parallel double variable array that stores the values, or by separately testing each text box BEFORE converting it - and skipping the zero values - but both options seem pretty clunky.
In Access, this problem was easily solved by using the "NZ" function to convert all Nulls to 0. Is there something similar in VB2005? Or is there another way to get the Cdbl(txtJanRevenue.Text) function to throw a zero when the txtJanRevenue.Text is "$0.00" = which apparently gets read as the null string?