# Thread: If Statement not working

1. Registered User
Join Date
Nov 2016
Posts
28

## Unanswered: If Statement not working

Hi guys,

I have a simple If statement which doesn't appear to be working - it's essentially:

If a = 0 Then
b = c
Else
b = c * d (d is a calculated small corrective factor)
End If

In the line producing the wrong results, a is a small but non-zero value (0.000055), but the If statement is producing b = c regardless. I'm confident that it's not some weird fluke where d = 1, and have tested the hypothesis that a <> 0 is being read as a = 0 in the If statement, by changing the decimal value of c, and changing the Then term to b = c + constant, and it does appear to be computing as if a = 0 (I even tried changing the If statement to "If a * 1000000 = 0 Then, in case it was rounding a to something, but that didn't work either).

Has anyone had experience with If statements computing incorrectly? Are there any workarounds or other functions I can use to solve this efficiently?

Many Thanks

2. Registered User
Join Date
Apr 2014
Location
Kentucky
Posts
602
are A,B,C defined as double?

3. Registered User
Join Date
Nov 2016
Posts
28
Yes, all the variables are doubles.

4. Registered User
Join Date
Nov 2016
Posts
28