Reputation: 49
I'm new to crystal reports and .net technologies. I have recently started working on them and I want to know whether the crystal report expressions can be converted to an equivalent vb code, so I can use them in SSRS reports.
Also the below crystal report expressions by itself looks like sort of vb code(someone correct me if I am wrong).
Crystal report formula:
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 Code:
Public Function Test(ByVal profit As String) As String
{
//crystal report expressions as vb code?
}
Now can I convert this crystal formula into vb code?
Note: Availability in the formula is the stored procedure name and followed by a field name
.
Upvotes: 0
Views: 652
Reputation: 3003
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
Upvotes: 1