Programming Part 1
Programming Part 1
PART 1
Programming is a simple and pure form of art which cannot be
replicated
This document has little theoretical knowledge of programming
CHIBI TINODAISHE M
[email protected]
0781081816
RESERVED WORDS
Also known as keywords are words with pre-defined meaning in a specific
programming language for example VB.NET has Dim , if , End etc
Reserved words must not be used as variables as they have an inbuilt function
already spelt out to them within the languages.
VARIABLE
Is a name given to a memory location that stores a certain value or string.
LOCAL VARIABLES
Known as private variables
CONSTANTS
Is a variable whose value does not change during program execution.
IDENTIFIERS
A unique label of a data item or element of a program and comprises of 1 or more
character.
PROCEDURES
Self contained module that does not return a value .
Sub program that performs a special task within the main program
In vb procedures start with the keyword Private Sub , Public Sub
Functions
A self contained module that returns a value to the part of a program which calls it
every time it is called or executed.
(more on functions see chiby function pdf)
SYNTAX
Is a the grammatical rules governing sentence construction in that language.
SEMANTICS
The meaning attached to statements and the way they are used in a certain language.
ARRAYS
Is a static data structure which stores variables of the same data type.
An array position always starts from zero.
array(0) = 10
array(1) = 20
array(2) = 30
array(3) = 40
In the above code we declare an Integer Array of four elements and assign the value to array
index . That means we assign values to array index 0-4.
Module Module1
Sub Main()
Dim array As Integer() = New Integer(3) {}
array(0) = 10
array(1) = 20
array(2) = 30
array(3) = 40
For i As Integer = 0 To array.Length - 1
Console.WriteLine(array(i))
Next
Console.ReadKey()
End Sub
End Module
Myarray.length
names(0) = "Chiby"
names(1) = "Tatenda"
We can access the Arrays elements by providing its numerical index, the
above statement we access the second value from the names Array.
End Module
How to Use For Each loop with Arrays ?
Dim array As Integer() = {10, 30, 50}
'array declaration
For Each element As Integer In array
MsgBox(element)
Next
Array Sort
You can sort the arrays in ascending order as well as descending .
We can use Array.Sort method for sorts the elements in a one-
dimensional array.
Also we can use Array.Reverse method for reverses the sequence of the
elements in the entire one-dimensional Array.
Module Module1
Sub Main()
Dim names(4) As String
names(0) = "Chiby"
names(1) = "Tatenda"
names(2) = "Letwin"
names(3) = "Salome"
names(4) = "Tacue"
names(5) = "Marange"
names(6) = "Faith"
End Module
OUTPUTTING AN ARRAY
CONTACT: 0781081816
EMAIL : [email protected]
ISAIAH 43 VS 2
THANK YOU
===============================================================================