VB Tutorial
Tools
Free Downloads
Free Link Directory

Basics
Data Types
Windows Forms
Buttons
Check Box
Text Box
Combo Box
Radio Buttons
Progress Bar
Color & Font Dialogs
Open & Save Dialogs
Process Control

More Complex Examples
Audio Player
Rotating Rectangle


 


Basics with Visual Basic 2008

Welcome to this tutorial. I have to say congratulations on choosing Visual Basic as your first programming language as it is easy to use for creating forms and controls. It also gives you a genuine Microsoft Windows approach. So lets start.

Data Types

No matter in what language we program we always have the same principles and basic instructions. Even though the actual coding and methods might differ a bit, we have some basics that always apply. Some of these basics are variables and constants. Programs use variants and constants to store information (data) in memory.

Constants
are used to declare information that are constant and can not change again. Constants are declared at modular level and can be used over and over again without having to type the actual data or string again.
Example:
Public Const Name As String = "John Peter Osborne"
In this example we declared a constant and called it
Name. In the constant Name we stored the string representation, "John Peter Osborne". Now every time we want to refer to the name "John Peter Osborne" we can simply type Name and the program will return the value stored in the constant Name. Easy don't you think?

Variables
are used to store data that can change all the time through the program and therefore the name Variable. Variables can be declared at almost any level including classes, modules, and functions.
Example:
Dim Total As Integer = 12
In this example we declared an Integer called
Total and stored the value 12 in it. Should you now refer to Total the program will return the value 12. Now can change the value and declare that Total = 24 and the program will return the value 24 every time you refer to Total, until you change it again.

When we declare constants and variables as data types like "integer" in the example above, we have to decide exactly what type of data we are going to store. Different data types take up different memory bites and can slow your program down. Inspect the data types in the following table to see what they are used for.

Visual Basic type Common language runtime type structure Nominal storage allocation Value range
Boolean Boolean Depends on implementing platform True or False
Byte Byte 1 byte 0 through 255 (unsigned)
Char (single character) Char 2 bytes 0 through 65535 (unsigned)
Date  DateTime 8 bytes 0:00:00 (midnight) on January 1, 0001 through 11:59:59 PM on December 31, 9999
Decimal Decimal 16 bytes 0 through +/-79,228,162,514,264,337,593,543,950,335 (+/-7.9...E+28) with no decimal point; 0 through +/-7.9228162514264337593543950335 with 28 places to the right of the decimal;

smallest nonzero number is +/-0.0000000000000000000000000001 (+/-1E-28)
Double (double-precision floating-point) Double 8 bytes -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values;

4.94065645841246544E-324 through 1.79769313486231570E+308
for positive values
Integer Int32 4 bytes -2,147,483,648 through 2,147,483,647 (signed)
Long (long integer) Int64 8 bytes  -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807 (9.2...E+18 ) (signed)
Object Object (class) 4 bytes on 32-bit platform

8 bytes on 64-bit platform
Any type can be stored in a variable of type Object
SByte SByte 1 byte -128 through 127 (signed)
Short (short integer) Int16 2 bytes -32,768 through 32,767 (signed)
Single (single-precision floating-point) Single 4 bytes  -3.4028235E+38 through -1.401298E-45 for negative values;

1.401298E-45 through 3.4028235E+38
for positive values
String (variable-length) String (class) Depends on implementing platform 0 to approximately 2 billion Unicode characters
UInteger UInt32 4 bytes 0 through 4,294,967,295 (unsigned)
ULong UInt64 8 bytes 0 through 18,446,744,073,709,551,615 (1.8...E+19 ) (unsigned)
User-Defined (structure) (inherits from ValueType) Depends on implementing platform Each member of the structure has a range determined by its data type and independent of the ranges of the other members
UShort UInt16 2 bytes 0 through 65,535 (unsigned)

In scientific notation, "E" refers to a power of 10. So 3.56E+2 signifies 3.56 x 102 or 356, and 3.56E-2 signifies 3.56 / 102 or 0.0356.

I know it might seem a bit much at first glance, but don't worry we'll go through it step by step in this tutorial. If you liked this article then Please Thumb This Up with a short review - Stumble It!
Let's continue to the next page.


Email us at: info@pro2visual.com
 

Get your Website Listed on our Free Link Banner Directory
Advertise your site with your own unique link banner we will also provide text links to your site.

Popular Articles

Moving a borderless form in vb.net

ComboBox1.Items.Add

Link Progress Bar with Timer in vb.net

How to open a folder using the process control

Start Vb.net programming. No get rich quick scam

How to Convert the Date Format

Click here for Industry Leading Development Softwa