{"id":351,"date":"2007-12-30T21:46:28","date_gmt":"2007-12-31T04:46:28","guid":{"rendered":"http:\/\/members.crystalreportsbook.com\/crystal-reports-xi\/b-2-data-types-and-variables\/"},"modified":"2007-12-30T21:46:28","modified_gmt":"2007-12-31T04:46:28","slug":"b-2-data-types-and-variables","status":"publish","type":"post","link":"http:\/\/www.crystalreportsonlinetraining.com\/training\/b-2-data-types-and-variables\/","title":{"rendered":"B. 2 Data Types and Variables"},"content":{"rendered":"<h2>Simple Data Types<\/h2>\n<p>Basic syntax uses the same data types as Crystal syntax. However, the naming convention varies slightly. In Crystal syntax all data type have &#8220;Var&#8221; at the end (e.g. NumberVar, StringVar, etc.) Basic syntax doesn&#8217;t use the &#8220;Var&#8221; suffix after each data type. It simple uses the data type name by itself: Boolean, Number, Currency, String, DateTime, Date, and Time.<\/p>\n<h2>Declaring Variables<\/h2>\n<p>To use a variable in a formula, you first have to declare it. This consists of giving it a name and specifying its data type. Declaring a variable follows the format of declaring the variable using the Dim keyword followed by the variable name. Use the As keyword to specify the data type.<\/p>\n<p>         <code_Single>Dim var As dataype<\/code_Single><\/p>\n<p>Just like Crystal syntax, there are three keywords for setting a variable&#8217;s scope (whether other formulas can reference it): Dim, Global, and Shared.<\/p>\n<p>Dim: The variable can only be seen within the current formula. The variable is private to that formula and can&#8217;t be used anywhere else in the report. This is the default scope if you don&#8217;t specify it.<\/p>\n<p>Global:  The variable can be seen within any formula inside the same report. Sub-reports do not have access to the variable.<\/p>\n<p>Shared: Similar to Global, but the variable can also be seen within sub-reports.<\/p>\n<p>         <code_Single>Dim HireDate As Date<\/code_Single><br \/>\n         <code_Single>Shared AffiliateCities() As String<\/code_Single><\/p>\n<h2>Variable Assignment<\/h2>\n<p>In Basic syntax, to assign a value constant to a variable use the equal sign.<\/p>\n<p>         <code_Single>X = 5<\/code_Single><br \/>\n         <code_Single>Y = &#8220;Mr. &#8221; &amp; {Customer.Last Name}<\/code_Single><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simple Data Types Basic syntax uses the same data types as Crystal syntax. However, the naming convention varies slightly. In Crystal syntax all data type have &#8220;Var&#8221; at the end (e.g. NumberVar, StringVar, etc.) Basic syntax doesn&#8217;t use the &#8220;Var&#8221; suffix after each data type. It simple uses the data type name by itself: Boolean, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,1],"tags":[],"class_list":["post-351","post","type-post","status-publish","format-standard","hentry","category-appendix-b-basic-syntax-reference","category-crystal-reports-xi","entry"],"_links":{"self":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts\/351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/comments?post=351"}],"version-history":[{"count":0,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts\/351\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/media?parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/categories?post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/tags?post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}