Background:
This article discusses how to use VB functions in RDL and Page Reports
Steps to Complete:
AddDate() example:
-
In your RDL/Page Report, add a TextBox to your report.
-
Click the Script control within the report, and you should be taken to a blank script editor.
-
Within that script editor screen, add this AddDate() function:
Public Function AddDate()
AddDate = DateAdd(DateInterval.Day, 0, Today)
End Function
-
-
After adding the code, go back to the designer and locate the TextBox you added to the report. Enter this expression into your TextBox -> =Code.AddDate()
-
-
Then hit Preview and you should be able to see the current date and time on the report output.
AddAnotherDate() example:
-
In your RDL/Page Report, add a new TextBox to your report.
-
Click the Script control within the report, and you should be taken to a blank script editor.
-
Within that script editor screen, add this AddAnotherDate() code:
Public Function AddAnotherDate(ByVal iInput)
If iInput <> 0 Then
AddAnotherDate = DateAdd(DateInterval.Day, iInput, Today)
End If
End Function
-
After adding the code, go back to the designer and locate the new TextBox you added to the report. Enter this expression into that TextBox -> =Code.AddAnotherDate(1)
-
The “1” represents a parameter that we are going to pass into the function so that we can get our desired output.
-
-
Then hit Preview and you should be able to see the date and time on the report output.
Resources:
For more information, refer to our documentation here:
Tags:
Evan Warren