Data Types: Computers treat different types of data differently. Numbers are not dealt with in the same way that words are. For example, to a computer 4 + 8 means “add 4 and 8” so the result is 12. However “4” + “8” means combine the character “4” and the character “8”. In this case the result is the characters “48”.
Here are some of the more common data types:
Integer: whole numbers (no decimals or fractions)
String: letters and numbers that are just characters Examples: Terry, This is a string, She is 15 years old, AER$643*9&HBY.
Boolean: this data type can be either True or False
There are several other data types but, as a beginner, these will be the types you will use most often.
In your program code you need to identify the type of data you are using so the computer will know how to deal with that data. This is done by using a “dim” statement at the beginning of the block of code. In the examples below the code and the result of executing the code are shown.
|dim n as integer //identify the type of data
n = 4 + 8
|The result is an integer with a value of 12|
|dim t as string //identify the type of data
t = “4” + “8”
|The text in TextField1 would be the string “48”|
|dim textInField as boolean //identify the type of data
if TextField1.text <> “” then
|The boolean textInField would be set to true or false depending on whether or not there is any text in TextField1. You would refer to this boolean like this:
if textInField = true then
TextField1.textSize = 18