将水晶报表表达式转换为vb代码

时间:2016-12-13 05:45:55

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

我是水晶报道和.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

1 个答案:

答案 0 :(得分: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