The file named vb_ide_01.vbproj, which is actually written in XML, contains
information about the project, including descriptions of properties. These can
usually be changed by choosing Project|Properties or by right-clicking on the
project name in the Solution Explorer.
Here is what a project file looks like in text form. Notice the constant repetition of
the keyword Assembly. We explain the other important keywords used here,
Non-Numeric Literals
Non-numeric literals include Boolean, Date, and Char data types. The Boolean
data type represents True or False and takes up four bytes in VB .NET, as opposed
to two bytes in VB6.
Table 3-2. Correspondence between Numeric Types
VB .NET TYPE .NET FRAMEWORK TYPE VB6 TYPE
Byte System.Byte Byte
Boolean System.Boolean Boolean
Decimal System.Decimal NONE
NONE NONE Currency
Double System.Double Double
Short System.Int16 Integer
Integer System.Int32 Long
Long System.Int64 NONE
Single System.Single Single
CAUTION In VB .NET Beta 1, True was +1 (as in other .NET languages). Starting
in Beta 2, it goes back to –1. More precisely, in "logical operations" in VB and in
conversions to numeric types, True will be –1, not 1. However, when a Boolean in
VB .NET is passed out of VB , it is treated as 1 when it is converted to a number in
that language. We think this was the wrong decision, because the point of .NET
is to have as much cross-language compatibility as possible. As long as you use
the built-in constants for True and False, you will be fine. If you use numeric values,
you may run into problems!
Expressions, Operators, and Control Flow
59
The Date data type represents a date and/or a time. As in VB5, you surround a
literal that represents a date and time by two #s, as in #Jan 1, 20001#. If you do not
specify a time, the date literal will be assumed to be that date at midnight.
The Char data type represents a single Unicode character. The Unicode system
allows 65,536 characters, which is enough to encompass all known alphabets. Characters
are usually surrounded by single quotes followed by a C, as in: “H”C, but if
you want to get an actual Unicode character, simply use the Chr built-in function.
For example, Chr(&H2153) is a 1⁄3 in the Unicode charts, although you may not see
it as such on some operating systems when the program runs. Note that if you use
one character within quotes without the “C” suffix, you get a String rather than a
Char and the two are not automatically convertible (more on Option Strict later in
this chapter).
Declaring Variables
The way to declare a variable in VB .NET within a procedure or function is with the
Dim plus As keywords, just as in VB6. You use the equals sign to make the assignment:
Dim foo As String
foo = "bar"
Note that unless you change the defaults for VB .NET, you must declare a variable
before using it. (The optional Option Explicit introduced in VB4 is now the default.)
In VB .NET, you can initialize a variable when you declare it. For example:
Dim salesTax As Decimal = 0.0825D
declares a variable called salesTax and gives it the initial value .0825 of the new
Decimal type. You can also use any valid VB .NET expression to give the initial
assignment. For example:
Dim startAngle As Decimal = Math.PI
gives startAngle the built-in value for the mathematical constant π by using a constant
built into the System.Math class.
No comments:
Post a Comment
This is Good Computer Information Blog.they will give
best information about computer.