Using Logic of Programs With Conditions
Using Logic of Programs With Conditions
10 num1
20 num2
30 sum
Variables
Data Types
It specify what type of value a respective variable can hold.
Data Type Byte Char Integer Double Long Short Single String Type System.Byte System.Char System.Int32 System.Double System.Int64 System.Int16 System.Single System.String
Date
Boolean Object
System.Date
System.Boolean System.Object
Using Operators
Operators are tools for some predefined operations The operators that are used in flowcharts are: Arithmetic operators Relational operators Logical operators
Procedures in VB.NET
It is a series of statements that are executed when called. it allow us to handle code in a simple and organized fashion. In VB.NET we can create two different type of procedures. 1. Sub Procedure 2. Function Procedure
Sub Procedures
They are methods which do not return a value. Each time when the Sub procedure is called the statements within it are executed until the matching End Sub is encountered. Syntax
[AccessSpecifier] Sub <procedure_name>([parameters]) .. .. End Sub
Function Procedures
Function is a method which returns a value. Functions are used to evaluate data, make calculations or to transform data. Syntax
[AccessSpecifier] Function <procedure_name>([parameters]) as <DataType> .. Return <value> End Function
Conditional Statements
If....Else statement If conditional expression is one of the most useful control structures which allows us to execute a expression if a condition is true and execute a different expression if it is False.
Syntax
If condition Then [statements] Else If condition Then [statements] Else [statements] End If
Loops
While loop While loop keeps executing until the condition against which it tests remain true.
Syntax
While condition [statements] End While
Loops (Contd..)
Do Loop The Do loop can be used to execute a fixed block of statements indefinite number of times. The Do loop keeps executing it's statements while or until the condition is true. Two keywords, while and until can be used with the do loop. The Do loop also supports an Exit Do statement which makes the loop to exit at any moment. Syntax
Do [statements] [Exit Do] [statements] Loop [{while | Until} condition]
Loops (Contd..)
For Loop The For loop is the most popular loop. For loops enable us to execute a series of expressions multiple numbers of times. The For loop in VB .NET needs a loop index which counts the number of loop iterations as the loop executes.
Syntax
For index=start to end [Step step] [statements] [Exit For] [statements] Next
In VB.NET there are two ways in which we can call a function or procedure, viz, by Value or by Reference. The default being Call by Value. Passing a parameter by Reference means that if changes are made to the value of a variable passed, these changes are reflected back in the calling routine. (ByRef) Passing a parameter by Value means that if changes are made to the value of a variable passed, these changes are not reflected back in the calling routine. (ByVal)
Array
Are collections of values of the same data type. Contain elements that can be accessed using a single name and an index number representing the position of the element Syntax Dim arr_name(number-of-elements) as DataType Can be resized using the Redim statement Syntax ReDim arr_name(new-number-of-element)
Parameter arrays
Parameter arrays allow a variable number of arguments to be passed into a function member. The definition of the parameter has to include the params modifier, but the use of the parameter has no such keyword. A parameter array has to come at the end of the list of parameters, and must be a single-dimensional array. When using the function member, any number of parameters (including none) may appear in the invocation .
Syntax
Sub MinValue(ParamArray ByVal args() As Integer) As Integer .. End Sub
Enumeration
Enumeration is a related set of constants. They are used when working with many constants of the same type. It's declared with the Enum keyword. Example: