【问题标题】:Converting crystal report expressions to vb code将水晶报表表达式转换为vb代码
【发布时间】:2016-12-13 05:45:55
【问题描述】:

我是水晶报表和 .net 技术的新手。我最近开始研究它们,我想知道水晶报表表达式是否可以转换为等效的 vb 代码,以便在 SSRS 报表中使用它们。

另外,下面的水晶报表表达式本身看起来像是一种 vb 代码(如果我错了,请有人纠正我)。

水晶报表公式:

local StringVar x :="";

if not isnull({Availability.Address}) and trim  {Availability.Address}) <> "" 
and {Availability.Address} <> {Availability.Building} 
then x := x + {Availability.Address} + chr(10);

if not isnull({Availability.Park}) and trim({Availability.Park}) <> "" 
then x := x + {Availability.Park} + chr(10);

if not isnull({Availability.City}) and trim({Availability.City})
<> "" then if not isnull({Availability.State}) 
then x := x + {Availability.City} + ", "
else  x := x + {Availability.City} + " ";

if not isnull({Availability.State}) and trim({Availability.State})    
<> "" then x := x + {Availability.State} + " ";

if not isnull({Availability.Zip}) and trim({Availability.Zip})   
<> "" then     x := x + {Availability.Zip} + " ";
x;

VB 代码:

Public Function Test(ByVal profit As String) As String
{
    //crystal report expressions as vb code?
}

现在我可以把这个水晶公式转换成vb代码了吗?

注意:Availability in the formula is the stored procedure name and followed by a field name.

【问题讨论】:

    标签: c# vb.net reporting-services crystal-reports


    【解决方案1】:
    Function formula(ByVal address_1 As String, _
                    ByVal building_name_formatted_rpt As String, _
                    ByVal park_name As String, _
                    ByVal city As String, _
                    ByVal state As String, _
                    ByVal zip As String) As String
    
        Dim x As String = ""
    
        If Not IsDBNull(address_1) And Trim(address_1) <> "" And address_1 <> building_name_formatted_rpt Then
            x = x & address_1 & Chr(10)
        End If
    
    
        If Not IsDBNull(park_name) And Trim(park_name) <> "" Then
            x = x & park_name & Chr(10)
        End If
    
        If Not IsDBNull(city) And Trim(city) <> "" Then
            If Not IsDBNull(state) Then
                x = x & city & ", "
            Else
                x = x & city & " "
            End If
        End If
    
    
        If Not IsDBNull(state) And Trim(state) <> "" Then
            x = x & state & " "
        End If
    
    
        If Not IsDBNull(zip) And Trim(zip) <> "" Then
            x = x & zip & " "
        End If
    
        Return x
    End Function
    

    【讨论】:

    • 我收到此错误。 Function 'formula' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.
    猜你喜欢
    • 2011-07-28
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 2017-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多