Help with IF... Then... Else statement
Thank you. This seems to work. Here's the final function if anyone cares:
Public Function GroundCover(Input1 As String, Input2 As Integer, Input3 As
Double)
' Determine if input1 = flats
If Input1 = "Flats" Then
'Use Select Case input2 and multiply
'input3 by coresponding Number
Select Case Input2
Case Is = 4
Output = Input3 * 0.1406
Case Is = 6
Output = Input3 * 0.0625
Case Is = 8
Output = Input3 * 0.0351
Case Is = 9
Output = Input3 * 0.0278
Case Is = 10
Output = Input3 * 0.0225
Case Is = 12
Output = Input3 * 0.0156
Case Is = 18
Output = Input3 * 0.0087
Case Is = 24
Output = Input3 * 0.0039
Case Is = 30
Output = Input3 * 0.0025
Case Else
Output = "-"
End Select
Else
'Use second IF statement to check input1
'and multiply input3 by coresponding Number
If Not Input1 = "Flats" Then
'Use Select Case input2 and multiply input3
'by coresponding Number
Select Case Input2
Case Is = 4
Output = Input3 * 9
Case Is = 6
Output = Input3 * 4
Case Is = 8
Output = Input3 * 2.25
Case Is = 9
Output = Input3 * 1.78
Case Is = 10
Output = Input3 * 1.44
Case Is = 12
Output = Input3 * 1
Case Is = 16
Output = Input3 * 0.56
Case Is = 18
Output = Input3 * 0.45
Case Is = 24
Output = Input3 * 0.25
Case Is = 30
Output = Input3 * 0.16
Case Is = 36
Output = Input3 * 0.1111
Case Is = 48
Output = Input3 * 0.0625
Case Is = 72
Output = Input3 * 0.0278
Case Else
Output = "-"
End Select
End If
GroundCover = Output
End If
GroundCover = Output
End Function
|