In Module 3 you may have noticed that in the Properties window most of the properties of the form (or control) already had values. These values are referred to as default values—that is, values provided by Visual Basic .NET in the absence of direction from you, the programmer. Default values are necessary. When you first run your project, the form has to have some height, width, background color, and so on, even if you have not specified the values of these properties.
Variables similarly have default values. The default value of all numeric variables, whether whole numbers or floating point, is zero (0). The default value for Boolean is False, which also evaluates to zero. The default value for a String is an empty string, noted by a pair of double quotes with no space in between ("")
Ask the Expert
Question: Why is the size of the Char data type 2 bytes?
Answer: Fundamentally, computers work with numbers, so they store letters and other characters by assigning a number for each one. For the English language, the character set adopted by ANSI (American National Standards Institute) and ASCII (American Standards Committee for Information Interchange) used the numbers 0 th rough 255 to cover all alphabetical characters (upper- and lowercase), digits and punctuation marks, and even characters used in graphics and line drawing.
Of course, the world does not end at the shores of the United States. In addition to other languages such as German, French, and so on that share our basic alphabet but have characters that do not exist in English, there are languages such as Russian and Chinese with totally different alphabets. Different encoding systems were used to translate the characters in those locations to corresponding numbers.
With the increasing globalization of the economy, software was written for use in many different countries. The problem arose that a number may mean one character under ASCII/ANSI but another character in another country that used a different encoding standard.
The solution was Unicode. Unicode provides a unique number for every character, no matter which language. Of course, 256 numbers (2 A 8, or 1 byte) no longer was sufficient for all these characters. Therefore, the size of the Char data type in Visual Basic .NET is 2 bytes (2 a 16 or 65,536).
■ What is the main difference between the data types Integer and Long, on the one hand, and Single and Decimal on the other?
Integer and Long data types represent whole numbers, whereas Single and Decimal data types may represent a fractional number.
A signed number can be a positive or negative number, as opposed to an unsigned number, which can only be positive.
■ Which data type is the parent or root type in Visual Basic .NET?
The Object data type is the root data type in Visual Basic .NET.
Was this article helpful?