CrakED
01-07-2004, 04:49 PM
Hello,
I am interested in a way to simplify these if statements...
I think there is a way to load an array, but I am not sure how. Basically I need to take a variable with a numeric value and reassign the closest value (rounded down) to a number in a list.
Example:
My qualifying numberrs are 500, 520, 540, 560, 580, 600, 620, 640, etc, etc....
if strVar1 = 623 then strVar2 = 620
Here are the if statements which are now doing the job, howver I'd like to streamline the code.
If strScore > "500" And strScore < "510" Then
strScore = "500"
End If
If strScore >= "510" And strScore < "520" Then
strScore = "510"
End If
If strScore >= "520" And strScore < "530" Then
strScore = "520"
End If
If strScore >= "530" And strScore < "540" Then
strScore = "530"
End If
If strScore >= "540" And strScore < "550" Then
strScore = "540"
End If
If strScore >= "550" And strScore < "560" Then
strScore = "550"
End If
If strScore >= "560" And strScore < "580" Then
strScore = "560"
End If
If strScore >= "580" And strScore < "600" Then
strScore = "580"
End If
If strScore >= "600" And strScore < "620" Then
strScore = "600"
End If
I am interested in a way to simplify these if statements...
I think there is a way to load an array, but I am not sure how. Basically I need to take a variable with a numeric value and reassign the closest value (rounded down) to a number in a list.
Example:
My qualifying numberrs are 500, 520, 540, 560, 580, 600, 620, 640, etc, etc....
if strVar1 = 623 then strVar2 = 620
Here are the if statements which are now doing the job, howver I'd like to streamline the code.
If strScore > "500" And strScore < "510" Then
strScore = "500"
End If
If strScore >= "510" And strScore < "520" Then
strScore = "510"
End If
If strScore >= "520" And strScore < "530" Then
strScore = "520"
End If
If strScore >= "530" And strScore < "540" Then
strScore = "530"
End If
If strScore >= "540" And strScore < "550" Then
strScore = "540"
End If
If strScore >= "550" And strScore < "560" Then
strScore = "550"
End If
If strScore >= "560" And strScore < "580" Then
strScore = "560"
End If
If strScore >= "580" And strScore < "600" Then
strScore = "580"
End If
If strScore >= "600" And strScore < "620" Then
strScore = "600"
End If