我在 Report Builder 3.0 中的报告中有一个多值单字符串作为参数字段(例如 20124、20125)。现在我想拆分这个字符串,并显示“Summer 2012”而不是“20124”和“Fall 2012”而不是“20125”。我使用的是 Visual Basic。这是我在 Report Builder 3.0 自定义代码中创建的两个函数.错误出现在“If Right(yearterm)...”行的第二个函数中。它给了我一个语法错误。如果我写“String.Right”它给我错误:“'Right' is not a 'String' 的成员”。如果我取出整个“If 语句”,报告将运行,但“20124,20125”给我这个:“, 2012, 2012”。
我怎样才能使这项工作?
Public Function SplitParameterValues(ByVal parameter As Parameter) As String
Dim result As String
Dim a(0 To 10) As String
a = Split(parameter.Value, ",")
For i As Integer = 0 to a.length - 1
result = result +", " + YearTermTranslation(a(i))
Next
Return result
End Function
Public Function YearTermTranslation(ByVal yearterm As String) As String
Dim result As String
Dim term As String
Dim year = Left(yearterm, 4)
If Right(yearterm, 1) = 5
Then term = "Fall"
Else If Right(yearterm, 1) = 4
Then term = "Summer"
Else If Right(yearterm, 1) = 3
Then term = "Spring"
Else term = "Winter"
End If
result = term + " " + year
Return result
End Function