Hi, I'm having some trouble with trouble with an If statement in my program. It's a series of wind speed brackets to select the category from the Saffir Simpson Scale of hurricane classification. The problem I'm having is that it won't select the correct category based on the wind speed entered, e.g If I type 70 it will select cat 4, not cat 0.
The code for the if statements is:
'select correct category based on wind speed and store in array Dim sCategory As Integer 'no category or category one statement If txtWindSpeed.Text <= 73 Then sCategory = 0 ElseIf txtWindSpeed.Text >= 74 Then sCategory = 1 ElseIf txtWindSpeed.Text <= 95 Then sCategory = 1 End If 'category two statement If txtWindSpeed.Text >= 96 Then sCategory = 2 ElseIf txtWindSpeed.Text <= 110 Then sCategory = 2 End If 'category three statement If txtWindSpeed.Text >= 111 Then sCategory = 3 ElseIf txtWindSpeed.Text <= 130 Then sCategory = 3 End If 'category four statement If txtWindSpeed.Text >= 131 Then sCategory = 4 ElseIf txtWindSpeed.Text <= 155 Then sCategory = 4 End If 'category five statement If txtWindSpeed.Text >= 156 Then sCategory = 5 End If
I've tried as one big 'If Else If' statement but that didn't work at all. Really confused, its for a college assignment by the way, I'm a beginner!
Any help would be greatly appreciated! Thanks.
Edit: thinking about it more, would I better off using a select case statement for it?