What is IDE?
Integrated Development Environment
IDE stands for Integrated Development Environment. It is an environment design to help developers to build solutions in a quick & efficient way.
The IDE is what you see when you start Visual Basic, and it’s where you develop, edit, compile & debug your applications.
Visual Studio .NET provides an environment that is common to all Visual Studio languages such as such as VB, Visual C#, Visual J#, Visual C++.
(a) Menu System :
Menu is the one of the common elements. It contains options like File, Edit, View, Project, Build, Debug, Data, Window, etc.
The toolbar is a shortcut to the commonly used commands. By default, Standard toolbar is appearing on visual studio .NET screen.
Provides a set of controls divided into various categories like Common controls, All Windows Forms, Containers, Menus & Toolbars, Data, Components, Printing, Dialogs, Crystal reports & and General.
(d) Solution Explorer:
Like Window Explorer, this window gives the list of all the items of the solution you’re working with, including all the projects in it, and the items in those projects like forms, classes, database etc.
(e) The Server Explorer:
Server Explorer is a great tool to Create, modify, delete, and refresh database connections.
(f) The Properties Window (F4)
It will display the list of properties for the selected control. It is use to view or set the property at design time.
(g) Form Designer View
Forms are the windows on which controls are placed. It is the “base” on which user interface is build.
(h) Code Designer : (F7)
Code Designer is used to write or edit the code.
IntelliSense is what’s responsible for those boxes that open as you write your code, listing all the possible options and even completing your typing for you.
IntelliSense is made up of a number of options, including:
- List Members: Lists the members of an object.
- Parameter Info: Lists the arguments of procedure calls
- Quick Info: Displays information in tooltips as the mouse rests on elements in your code.
- Complete Word: Completes typed words.
- Automatic BraceMatching: Adds parentheses or braces as needed.
Variables are used to store (hold) values temporarily during the execution of the program. Variable has a name & data type. Dim statement is used to declare variables.
Example : You can declare variable as follows:
Dim Area As Integer Area = 100
In following example you can also declare & initialize the value as follows.
Dim Area As Integer = 100
Constants store values that remain same (constant) throughout the execution of an application. Const statement is used to declare the constant. There is user define constants & system define constants (intrinsic constants).
Const ConstantName [ As DataType ] = initialization
Const Pi As Double = 3.14 Const Msg = "Hello World"
Constants store values that remain same (constant) throughout the execution of an application. Enumeration is a set of related constants.
Enumerations provide a convenient way to work with sets of related constants, and to associate constant values with names. Visual Basic provides a number of useful enumerations (predefined enumeration).
Enum enumeration name [ As data type ] member list End Enum
The data type must be one of the integer types. You can specify Byte, Integer, Long, SByte, Short, UInteger, ULong, or UShort. By default is Integer.
Example : The following example assigns a constant to every day of the week.
Enum Days Sunday = 1 Monday = 2 Tuesday = 3 Wednesday = 4 Thursday = 5 Friday = 6 Saturday = 7 End Enum
To use constant in the enumeration, you refer to like this:
Msgbox(Days.Sunday) ‘It will display1
Msgbox(Days.Thursday) ‘It will display5
If you do not initialize a constant in an enumeration, then by default, the first constant in an enumeration is initialized to 0, and subsequent constants are initialized to a value of one more than the previous constant.
A comment is a remark or information embedded in the program, often explanatory text that is ignored by the compiler. For example, What is the purpose of the procedure? What is the use of variables? etc. A comment is used for documentation.
Ø Comments in VB start with an apostrophe (‘) & Visual Basic ignore whatever follows the apostrophe on the line. For example ‘ The following procedure calculates the average.
You can also give comments using REM keyword followed by a space. For example, REM The following procedure calculates the average.
Multiple Statements on one line :
Colon character is used to write multiple statements in one line.
For example :-
Dim A, B, C As Integer A=10 : B=70: C=60
Data Type of VB .NET:
Data Type means, what kind of data can be stored in a variable & how that data is stored.
Elementary Data Types :
Numeric Data Types
(a) Integral Numeric types (b)Nonintegral Numeric types
(a) Integral Numeric types :- It represents only whole numbers without fractional parts. (Positive, negative, &zero) Byte, SByte, Short, Ushort, Integer, UInteger, Long, Ulong .
(b)Nonintegral Numeric types :- It represents numbers with both integer and fractional parts.
Ex. Single, Double, Decimal
Integral Numeric Types :
It represents only whole numbers without fractional parts. (Positive, negative, & zero).
- Byte : (1 Byte): Its storage size is 1 Byte. It holds unsigned 1-byte integers ranging in value from 0 to 255. The default value of Byte is 0.
- SByte : (1 Byte): Its storage size is 1 Byte. It holds Signed 1-byte integers ranging in value from -128 to 127. The default value of SByte is 0.
- Short: (2 Byte): Its storage size is 2 Byte. It holds signed 2bytes integers ranging in value from -32,768 through 32,767. The default value of Short is 0.
- UShort : (2 Byte): Its storage size is 2 Byte. It holds unsigned 2bytes integers ranging in value from 0 through 65,535. The default value of UShort is 0. à
- Integer : (4 Byte) :Its storage size is 4 Byte. The default value of the Integer is 0.
- UInteger: (4 Byte) : It is Unsign Integer. Its storage size is 4 Bytes. The default value of UInteger is 0.
- Long : (8 Byte) : Its storage size is 8 Byte. The default value of Long is 0.
- ULong: (8 Byte) : (Unsign Long) Its storage size is 8 Byte. The default value of ULong is 0.
Non integral Numeric types :
(With Decimal point) It represents numbers with both integer and fractional parts.
- Single : (4 Byte): Its storage size is 4 Byte. Holds signed IEEE 32-bit (4-byte) single-precision floating-point numbers. The default value of Single is 0.
- Double : (8 Byte): Its storage size is 8 Byte. Holds signed IEEE 64-bit (8-byte) double-precision floating-point numbers. The default value of Double is 0.
- Decimal : (16 Byte): Its storage size is 16 Byte. The number of digits to the right of the decimal point can range from 0 to 28. The default value of Decimal is 0.
Char (2 Byte) : It is used to store only one character. It occupies 2 Byte.
String :The String data type is used to store text. The string can contain a series of letters, numbers, spaces, and other characters. Its storage size depends on implementing platforms.
The default value of String is Nothing (a null reference). Note that this is not the same as the empty string (value “”).
Framework Type : The corresponding type in the .NET Framework is the System.String class.
You can declare Variable Length String variable as follows:
Dim StrMsg As String StrMsg = “Hello World”
In following example, you can also declare & initialize the string as follows.
Dim StrMsg As String = “Hello World”
- There are quite number of string-handling functions built into Visual Basic. For example Left, Mid, Right etc
- Besides the string-handling functions built into Visual Basic, many .Net Framework functions are built into the String class that Visual Basic 2005 uses.
Boolean : It is used to store either True or False value. The default value of Boolean is False. Its storage size (data width) depends on the implementing platform.
Date (8 Byte) : Its storage size is 8 Bytes. Its value ranging from 1stJanuary 0001 to 31stDecember 9999. It holds date values, time values, or date and time values. The default value of Date is 0:00:00 (midnight) on 1stJanuary 0001.
Object : An Object data type is a universal data type, which can hold any type of data. The default value of Object is Nothing (a null reference). It occupies 4 Bytes on the 32-bit platform & 8 Bytes on the 64-bit platform.
Composite Data Types OR User Define Data Types
In addition to the elementary data types Visual Basic also supports, composite data types such as structures, arrays, and classes. You can build composite data types from elementary types and from other composite types.
Option Explicit Statement
- When Option Explicit statement is set to ON, you must explicitly declare all variables using the Dim or ReDim statements.
- By default it in ON, so you need to declare all the variables before they are used.
- When Option Explicit statement is set to OFF, all undeclared variables are treated as Object type.
' Force explicit variable declaration. Option Explicit On ……… ……… Dim A As Integer A = 10
‘ The following assignment statement produces a COMPILER ERROR because ‘ the variable Square1 is not declared and Option Explicit is set to ON. Square1 = 10 ‘ It will causes ERROR
‘If Option Explicit is set to ON, then we must declare the variable before it is used.
Option Strict Statement
- If Option Strict Statement is set to ON, Visual Basic prevents (disallows) implicit narrowing data type conversion.
- Visual Basic will not do automatically type conversion. Then Visual Basic will consider that an error.
- If Option Strict Statement is set to OFF, Visual Basic will do automatically implicit narrowing data type conversion. By default it in OFF.
' Force explicit variable declaration. Option Strict On ……… ……… Dim I As Integer Dim D As Double D = 3.14159 I = D
- ‘A compilation ERROR occurs if such a narrowing conversion fails.
- ‘ It will disallow implicit conversions from Double To Integer
- ‘To solve above problem either you have to make Option Strict Off or you have to
- ‘do specific type conversion as follows.
- I = Cint(D) ‘ Convert To Integer.
Option Compare Statement :
The Option Compare statement is used to specify the string comparison method, which is either Binary or Text for a class, module, or structure. By default text comparison method is Binary.
Option Compare Binary
Option Compare Text
Option Compare Binary, the following text sort order is produced.. A < B < E < Z < a < b < e < z
Option Compare Text, the following text sort order is produced. (A=a) < (B=b) < (E=e) < (Z=z)
‘ Set the string comparison method to Binary
Option Compare Binary :-
MsgBox(“AAA” < “aaa”) ‘It will return True, because A < a in Binary comparison
‘ Set the string comparison method to Text
Option Compare Text :-
MsgBox(“AAA” < “aaa”) ‘It will return False, because A=a in Text comparison
An operator is a symbol or character which allows us to manipulate data
- Arithmetic operators are ^, *, /, \, +, -, Mod
- Assignment operators are =, ^=, *=, /=, \=, +=, -=, &=
- Comparison or Relational operators are =, <>, <, <=, >, >=, Is, Like
- String Concatenation operators are &, +
- Logical or Bitwise operators are Not, And, AndAlso, Or, OrElse, Xor
- Miscellaneous operators are AddressOf, GetType Ø AndAlso & OrElse operator performs logical short-circuiting.