显示错误“预期结束语”

时间:2014-01-17 20:38:47

标签: vb.net reporting-services

我正在报告支付的金额和目标金额,我想在指标中添加一行。以下是指标的代码;但是,当我保存时,它显示错误end of statement expected。任何人都可以请求帮助,我是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 

2 个答案:

答案 0 :(得分:1)

我不确定你是否复制并粘贴了你的代码,结果很糟糕,但你有几个语法错误。试试这个:

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 

答案 1 :(得分:1)

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 

首先,函数名称不能包含空格。其次,Select Case与函数声明在同一行,AmtPaid/TargetAmt是不同的行。第三,您必须使用0.9而不是.9。如果您仍然遇到错误,则必须发布更多代码。