Hi
your "IF"statements are clear voor a human but a computer will interpret not like you would expext. Your if statments have a couple of faults.
- If you use a "OR" in a "If" statement then the computer will evaluate what is before and afther the "OR" and then evaluate the "OR" statement.
- When a value is converted to an boolean then it is always "True" unless its 0 then its "False".
- x <= y <= z is always "False". i cant explain why.
for exapmle the if statment:
if height = 170 or 210
will always be true because
step 1: if (height = 170) or (210)
step 2: if (False or True) or (True)
step 3: if (true)
as you see beacause the right boolean value is true (step 2) the if statement is always true.
i have simplified your code with this rules in mind and then i get:
If Height <= 168 Or Height = 228 Or Height = 258 Or Height = 345 Or Height = 365 Or Height = 395 Then
h0 = 12
h1 = 12
Else
h0 = 14
h1 = 14
End If
I would advice you to use a "select case" statment. your code would the look more like this:
Dim height = Height
Dim hValue = 0
Select Case Height
Case 0 To 168
hValue = 12
Case 200 To 208
hValue = 12
Case 228
hValue = 12
Case 258
hValue = 12
Case 345
hValue = 12
Case 365
hValue = 12
Case 395
hValue = 12
Case 424 To 424
hValue = 12
' TODO add more cases for hValue = 12 .......
Case 170
hValue = 14
Case 210
hValue = 14
Case 482
hValue = 12
Case 502
hValue = 12
' TODO add more cases for hValue = 12 .......
End Select
h0 = hValue
h1 = hValue
i hope that this code explains it self if it does not feel free to ask.
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com