Vb character set
Visual basic character set comprise of those characters that are used to write visual basic programs which includes the alphabet (A-Z), the digits (0-9) and special characters or symbols like # @ % & * ? etc.Data variables and constants
So far, all data you used in your project have been properties of objects. You have worked with the Text property of Text Boxes and the caption property of labels. Now it is time to consider working with value that are not properties. Basic allows you to set up locations in memory and give each location a name. You can visualize each memory location as a scratch pad; the contents of the scratch pad can change as the need arises. In this example, the memory location is called intmaximumIntMaximum = 100
IntMaximum
100
After executing this statement, the value of intMaximum is 100. You can change the value of intMaximum, use it in calculations. Or display it in a control.
In the preceding example, the memory location called intMaximum is a variable. Memory locations that can be changed during project execution are called variables; locations that hold data that cannot change during execution are called constants. For example, a customer's name will vary as the information for each individual is being processed. However, the name of the company and the sales tax rate will remain the same ( at for the day).
When you declare a variable or a named constant, visual basic reserve an area of memory and assigns it a name, called identifier. You specify identifier names according to the rules of Basic as well as some recommended naming conventions.
The declaration statements establish your project's variables and constants, give them name, and specify the type of data they will hold. The statements are not consider executable; that is, they are not executed in the flow of instructions during program execution.
Here are some samples declaration statement:
Dim strName. As string. ' Declare a string variable Dim intCounter. As integer. ' Declare an integer variable
Const cut discountrate As currency = .15 ' Declare a named constant
The next few paragraphs describe the data type, the rules for naming variables and constants, and the format of the declarations.
Const cut discountrate As currency = .15 ' Declare a named constant
The next few paragraphs describe the data type, the rules for naming variables and constants, and the format of the declarations.
Data Types
By default visual Basic variables are of variant data type. The variant data type can store numeric, data/time or string data. When a variable is declared, a data type is supplied for it that determines the kind of data they can store. The fundamental data type in visual Basic including variant are integer, long , single, double, string, currency, byte and Boolean. Visual Basic supports a vast of data type. Each data type ha limit to the kind of information and the minimum and maximum value it can hold. In addition, some type can interchange with some other types. A list of visual Basic simple data type are given below.Byte
Store integer value in range of 0 - 255
Integer
Store interger value in the range of ( -32,768) — (+2,147,483,463)
Single
Store floating point value in the range of (-3.4×10 ^-38) - (+3.4×10^38)
Long
Store interger value in the range of (-2,147,483,468) - (+2,147,483,468)
Double
Store large floating value which exceeding the single data type value
Currency
Store monetary value. It support 4 digits to the right of decimal point and 15 digits to the left
String
Use to store alphanumeric values. A variable length string can store approximately 4 billion characters.
Date/Time
Use to store date and time value. A variable declared as date type can store both date and time value and it can store date value 01/01/0100 up to 12/31/9999
Boolean
Boolean data type hold either a true or false value. These are not stored as numeric values and cannot be used as such . Values are internally stored as 1 (True) and 0 (False) and any non-zero value is considered as true.
Variant
Store any type of data and is the default visual Basic date type. In visual Basic if we declare a variable without any date type by default ( variant).The Data Type of a variable or constant indicate what type of information will be stored in the allocated memory space; perhaps a name, a dollar amount, a data, or a total. Note that the default data type is variant. If you do not specify a data type, your variables and type is that it's easy and the variables and constants change their appearance as needed for each situation. The dis disadvantage is that variant require more memory and operate less quickly than other data types. The best practices is to always specify the data type.
Different data type and their usage
Boolean
True or False value
Byte
A single ASCII character (code 0 to 255)
Currency
Decimal fractions, such as dollars and cents
Date
An eight- character data
Double
Double precision floating point unmbers with 14 digits of accuracy
Integer
Whole unmbers in the range – 32,768 to 32, 767
Long
Larger whole numbers
Single
Single precision floating point numbers with six digits of accuracy
String
Alphanumeric data; latter's, digits, and others characters
Variant
Converts from one type to another as needed
The most common types of variables and constants we will use are string, interger, and currency. When deciding which data type to use, follow this guideline. If the date will be used in a calculation, then it must be numeric ( usually integer or currency); if it is not used in a calculation, it will be string. Use currency as the date type for any decimal fraction in business applications single and double data type are generally used in scientific application.
Example of data types usage
Contents
Data Type
Reason
Social security number
String
Not used in calculation
Pay rate
Currency
Used in a calculation, contains a decimal point
Hours worked
Currency
Used in a calculation, may contain a decimal point (Currency can be used for any decimal fraction, not just dollars)
Phone number
String
Not used in a calculation
Quantity
Integer
Used in calculations, contains a whole number
0 Comments