【问题标题】:Showing error "end of statement expected"显示错误“预期语句结束”
【发布时间】:2014-01-17 20:38:47
【问题描述】:

我正在制作一份关于支付金额和目标金额的报告,并且我想包含一条带指标的行。以下是指标的代码;但是,当我保存它时,它会显示错误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 

【问题讨论】:

  • 你Q中的代码和你项目中的代码是一样的吗?如果是这样,它充满了语法错误。
  • 是的,这就是我项目中的代码。你能帮帮我吗?

标签: vb.net reporting-services


【解决方案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 

【讨论】:

  • 尝试删除 KPI 和指标之间的空格。这有帮助吗?
  • 没有变化!我在顶部运行了另一个函数(这是正确的并且正在运行),你认为这是问题吗??
  • 是的,您可能不得不发布该模块中的所有代码,或者只是查看语法错误的含义。
  • Public Function GetValue(Item,Item2, RowNum) If RowNum = 1 then PaidValue = 0 TargetValue = 0 end if IsNothing(Item) then TargetValue = TargetValue + Item2 return TargetValue end if IsNothing(Item2 ) then PaidValue = PaidValue + Item return PaidValue end if End Function
  • 对不起,但您必须将其完全格式化为您的程序中出现的格式到您的问题中。无法判断所有文本是否有任何问题。
【解决方案2】:
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。如果您仍然遇到错误,则必须发布更多代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多