[RESOLVED] problem comparing values
Hi everyone,
I am trying to read in a string containing numerical values and keep a running total of a field. The field contains values such as 000001.15 (preceeding zeros and 2 decimal points.)
my declarations are as follows
Dim runTotal_NetPaid_GT_ZERO(6) As Currency
Dim netPaid As Currency
netPaid = CCur(SH_NetPaid) ' field which contains the string
The problem I have is when I use "netPaid" to make a comparison.
Select Case netPaid
Case netPaid = 0
Case netPaid > 0
Case Else
End Select
Even though the value is zero in Debug, the highlighted code does not get executed. Any ideas on why this is?
Thanks for your help
Gogi
Re: problem comparing values
It is because you aren't using the Select Case quite right - the variable should only appear on the first line of it, and not on the actual Case's.
Re: problem comparing values
also check this for me...
Insert this line
Code:
MsgBox Format(netPaid, "$#,##0.00")
before the
Code:
Select Case netPaid
and tell me what do you get?
Re: problem comparing values
Hi
Thanks for the reply guys.
koolsid:
MsgBox Format(netPaid, "$#,##0.00") this gives me $14.00
netPaid = CCur(SH_NetPaid) gives me 14
which is why I thought 000000.00 will give me 0 therefore that select case should work.
si_the_geek:
I see your point, but how will I deal with values greater than 0. will this work
Case Is > 0. I suppose I should try, shouldn't I?
Thanks
Re: problem comparing values
Quote:
Case Is > 0. I suppose I should try, shouldn't I?
Yes you are right...
Code:
Select Case netPaid
Case 0
'your code
Case Is > 0
'your code
Case Else
'your code
End Select
Re: problem comparing values
Thanks for your hel guys, I can go home know.:)