 Home
 Products
 Integration
 Tutorial
 Barcode FAQ
 Purchase
 Company
VISUAL BASIC FUNDAMENTALS in .NET framework
VISUAL BASIC FUNDAMENTALS QR Code JIS X 0510 Decoder In VS .NET Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in .NET applications. Print QRCode In VS .NET Using Barcode encoder for .NET framework Control to generate, create Denso QR Bar Code image in VS .NET applications. The Const statement is used to declare a named constant. This statement has the general form
QR Code ISO/IEC18004 Scanner In .NET Framework Using Barcode recognizer for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications. Creating Bar Code In VS .NET Using Barcode drawer for .NET framework Control to generate, create barcode image in Visual Studio .NET applications. Const constant name As data type = value
Recognize Barcode In .NET Framework Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications. Draw Denso QR Bar Code In C# Using Barcode generator for .NET Control to generate, create Quick Response Code image in VS .NET applications. EXAMPLE 2.5
QR Code Drawer In Visual Studio .NET Using Barcode drawer for ASP.NET Control to generate, create QR Code image in ASP.NET applications. Draw Quick Response Code In Visual Basic .NET Using Barcode printer for Visual Studio .NET Control to generate, create QR Code image in Visual Studio .NET applications. Here are some typical named constant declarations: Encoding EAN 128 In Visual Studio .NET Using Barcode generator for .NET Control to generate, create GTIN  128 image in .NET applications. Painting USS Code 128 In VS .NET Using Barcode generator for .NET Control to generate, create Code128 image in .NET applications. Const TaxRate As Single = 0.28 Const Avogadro As Double = 6.0225D+23 Const MaxCount As Integer = 100
Make 1D In Visual Studio .NET Using Barcode printer for VS .NET Control to generate, create 1D image in VS .NET applications. International Standard Serial Number Generation In VS .NET Using Barcode generator for .NET framework Control to generate, create International Standard Serial Number image in Visual Studio .NET applications. Suffixes
Code 3/9 Generator In Java Using Barcode drawer for BIRT reports Control to generate, create Code 3 of 9 image in Eclipse BIRT applications. Generating GS1128 In None Using Barcode printer for Online Control to generate, create EAN / UCC  14 image in Online applications. Suffix
Code 39 Full ASCII Scanner In Visual Studio .NET Using Barcode recognizer for .NET framework Control to read, scan read, scan image in VS .NET applications. Generating USS Code 128 In None Using Barcode maker for Software Control to generate, create Code 128 Code Set C image in Software applications. % & ! # $
Encode Barcode In VB.NET Using Barcode generation for .NET framework Control to generate, create bar code image in Visual Studio .NET applications. UPCA Supplement 2 Encoder In None Using Barcode encoder for Software Control to generate, create UPCA image in Software applications. EXAMPLE 2.6
EAN13 Supplement 5 Drawer In .NET Framework Using Barcode drawer for ASP.NET Control to generate, create GTIN  13 image in ASP.NET applications. Making Barcode In None Using Barcode encoder for Font Control to generate, create bar code image in Font applications. Shown below are several variables whose data types are defined by suffixes. Variable
Index% Counter& TaxRate! Ratio# CustomerName$
The use of suffixes is derived from earlier versions of the Basic language, and is included in Visual Basic largely for purposes of consistency and backward compatibility. Modern programming practice encourages the use of explicit data type declarations rather than suffixes. Hence, we will not make use of suffixes elsewhere in this book. Data Type integer long integer single double string
Data Type integer long integer single double string
Rather than declaring a data type explicitly (using a Dim or Const statement), a variable or named constant can be associated with a data type by adding a singlecharacter suffix to the end of the variable/constant name. Several of the more commonly used suffixes are listed below. AM FL Y
TeamFly
The first line declares TaxRate to be a singleprecision real constant whose value is 0.28. The second line defines Avogadro s number as a doubleprecision real constant whose value is 6.0225 1023. The last line declares MaxCount as an integer constant whose value is 100. Note that the values assigned to TaxRate, Avogadro and MaxCount will remain unchanged throughout the program. VISUAL BASIC FUNDAMENTALS
[CHAP. 2
UserDefined Data Types It is sometimes convenient to define a multicomponent data type whose individual components are standard data items (i.e., integers, singleprecision reals, strings, etc.). Visual Basic allows such data types to be defined, and it permits variables to be associated with these data types. Moreover, the components (called members) within such variables can easily be accessed individually. In general terms, the data type definition is written as Type data type name member name 1 As data type 1 member name 2 As data type 2 . . . . . End Type
To associate a variable with a userdefined data type, we simply write
Dim variable name As userdefined data type
The components (members) of a userdefined variable can be accessed individually as variable name.member name These components can be used in the same manner as ordinary variables. Thus, they can appear within expressions, and they can be assigned values (see Secs. 2.5 and 2.10). EXAMPLE 2.7
Here is a typical userdefined data type. This data type might be useful in a customer billing application. Type Customer CustomerName As String AcctNo As Integer Balance As Single End Type
Once the data type has been defined, we can declare one or more variables of this data type, as follows. Dim OldCustomer As Customer, NewCustomer As Customer
We can then refer to the individual variable members as
OldCustomer.CustomerName OldCustomer.AcctNo OldCustomer.Balance NewCustomer.CustomerName NewCustomer.AcctNo NewCustomer.Balance and so on.
2.5 OPERATORS AND EXPRESSIONS Special symbols, called arithmetic operators, are used to indicate arithmetic operations such as addition, subtraction, multiplication, division and exponentiation. These operators are used to connect numeric constants and numeric variables, thus forming arithmetic expressions. CHAP. 2] VISUAL BASIC FUNDAMENTALS
The standard arithmetic operators are Addition: Subtraction: Multiplication: Division: Exponentiation: + * / ^ (plus sign) (minus sign) (asterisk) (slash) (caret, or upwardpointing arrow) When arithmetic operators appear within an arithmetic expression, the indicated operations are carried out on the individual terms within the expression, resulting in a single numerical value. Thus, an arithmetic expression represents a specific numerical quantity. EXAMPLE 2.8
Several arithmetic expressions are presented below.
2 * j + k 1 first + second third 4 * Pi * Radius ^ 3 / 3 b ^ 2 (4 * a * c) 2 * (j + k 1) (a ^ 2 + b ^ 2) ^ 0.5 (5 / 9) * (F 32) (2 * x 3 * y) / (u + v) Each expression represents a numerical quantity. Thus, if the variables a, b and c represent the quantities 2, 5 and 3, respectively, the expression a + b  c will represent the quantity 4. Visual Basic also includes two additional arithmetic operators: Integer division Integer remainder \ (backward slash) In integer division, each of the two given numbers is first rounded to an integer; the division is then carried out on the rounded values and the resulting quotient is truncated to an integer. The integer remainder operation (Mod) provides the remainder resulting from an integer division. EXAMPLE 2.9
The results of several ordinary division, integer division and integer remainder operations are shown below. 13/5 = 2.6 8.6/2.7 = 3.185185 8.3/2.7 = 3.074074 8.3/2.2 = 3.772727 13\5 = 2 8.6\2.7 = 3 8.3\2.7 = 2 8.3\2.2 = 4 13 Mod 5 = 3 8.6 Mod 2.7 = 0 8.3 Mod 2.7 = 2 8.3 Mod 2.2 = 0 An arithmetic expression can be composed of a single numerical constant or a single numerical variable as well as some combination of constants, variables and operators. In any event, every numerical variable that appears in an arithmetic expression must be assigned a specific value before it can appear in the expression. Otherwise, the expression could not be evaluated to yield a specific numerical result.

