Reputation: 51
I am making a report on the amount paid and the target amount, and I want to include a line with indicators. Following is the code for the indicator; however, when I save it shows me the error end of statement expected
. Can anyone please help, I am new to Visual Basic.
Function KPI Indicator(AmtPaid As Decimal, TargetAmt As Decimal) As String Select Case
AmtPaid/TargetAmt
Case Is>= 1.5
Return "Green"
Case Is>=.90
Return "Yellow"
Case Else
Return "Red"
End Select
End Function
Upvotes: 1
Views: 2362
Reputation: 802
Function KPI_Indicator(AmtPaid As Decimal, TargetAmt As Decimal) As String
Select Case AmtPaid/TargetAmt
Case Is>= 1.5
Return "Green"
Case Is>=0.9
Return "Yellow"
Case Else
Return "Red"
End Select
End Function
First, name of function can't contain spaces. Second, Select Case
was in same line as Function declaration and AmtPaid/TargetAmt
was is different line. Third, you must use 0.9
instead of .9
. If you are still getting errors, you'll have to post more code.
Upvotes: 1
Reputation: 2758
I'm not sure if you copied and pasted your code and it turned out badly, but you have several syntax errors. Try this:
Function KPIIndicator(AmtPaid As Decimal, TargetAmt As Decimal) As String
Select Case (AmtPaid/TargetAmt) 'select case was in the same line as the function declaration and didn't have anything following it.
Case Is>= 1.5
Return "Green"
Case Is>=.90
Return "Yellow"
Case Else
Return "Red"
End Select
End Function
Upvotes: 1