Creating Formulas with Crystal Syntax
Over the past few releases, Crystal syntax and Basic syntax have moved closer together, through the development of similar functions and operators. In the next section, we'll have a look at some of the remaining differences.We'll be using a project called CrystalSyntax_basic to look at this syntax. This project is available in the download code from www.wrox.com, or you could build it from scratch by following the instructions. If you decide to build it yourself, create a Windows Application now and call it CrystalSyntax_basic. Add the customer sales report (which should be in the download sample under the path CrystalReports\Chapter07\customer_sales.rpt) into the project by right-clicking on the project name in Visual Studio .NET and selecting Add | Add Existing Item... and then browsing to the report.We're now in a position to drag and drop a CrystalReportViewer onto the Form, and also a ReportDocument component. When the dialog box opens to request which type of ReportDocument component you need, select CrystalSyntax_basic.customer_sales.Insert the following code into the Form_Load event:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim myReport As New customer_sales()
CrystalReportViewer1.ReportSource = myReport
myReport.Load()
End Sub
Now compile and run it, to make sure all is well. It should look like this (we have set the DisplayGroupTree property in the CrystalReportViewer properties to False here, in the interests of visual clarity):

We are now ready to go and look at the syntax behind this report.
Differences from Basic Syntax
To start with, a Crystal syntax formula does not require the Formula = tag at the end to output the formula results. This is the statement from the Local_Customer_Flag formula field in the customer sales report. You can access this field by opening the report in Visual Studio .NET, selecting View | Other Windows | Document Outline from the main toolbar, and in the tree that appears selecting Formula Fields and right-clicking on Local_Customer_Flag, and then selecting Edit.

A Basic syntax statement is shown below:
If {Customer.Country} = "USA" Then Formula = "Local Customer" else Formula =
"International"
By default, a Crystal syntax formula will display the last value that is calculated within the formula, as shown below:
If {Customer.Country} = "USA" Then "Local Customer" else "International"
Also, since Crystal syntax was created before Basic syntax, there were a number of Crystal Reports functions that were actually reserved words within Visual Basic. These functions have been given alternative names, which means that a function in Crystal syntax and one in Basic syntax can now be named differently from each other.
A list of common functions that are different between the two syntaxes is available in Appendix C.