Revision
Revision
What is a constant?
Arrays in Programming
Problem
If you want to capture 10 numbers and then manipulate them in
some way you would currently have to declare 10 separate
variables.
varAvg = (varNum1 +varNum2 + varNum3 + varNum4 + varNum5 + varNum6 + varNum7 + varNum8 + varNum9 +
varNum10)/10
Arrays in Programming
Arrays
An array is a list of sequential memory locations of the same data type. An
array is identified by a unique name and each element within the array is
addressed by its index(subscript) number.
Index: 1 2 3 4 5 6 7 8 9 10
arrNumbers(2) = 20
Arrays in Programming
Basic Array Definition
1. Every element in an array has to be of the same data
type (all integers, all Booleans, all strings, etc).
2. Each element is addressed by its index number,
starting at 0.
3. It’s good practice to make the array a set size before
putting values in it.
Declaring an Array
Dim ArrayName(UpperSubscript) As DataType
• ArrayName is the variable name of the array
• UpperSubscript is the value of the array's
highest subscript
• Must be a positive whole number
• DataType may be any Visual Basic data type
• VB knows an array is declared when name is
followed by parentheses with number of
elements
Arrays in Programming
Declaration ( 1 dimensional )
Array Name
This declaration sets up 10 consecutive memory
locations because VB.net includes the a zero
index arrNumbers(0) … arrNumbers(9)
Declaring an Array
In BASIC, arrays are declared (created, instantiated)
using the DIM (short for DIMENSION) statement
Includes the name of the array, and its size, e.g.
varSum = 0
For index = 0 to 9
varSum = varSum + arrNum(index)
Next
Record Structure
Student (StudentNO, Name,Surname,Dob,YearLevel, House)
Attribute Data Type
StudentNO String
Name String
Surname String
Dob Date
YearLevel Integer
House String
HTML XML
Browser interprets the tag. A browser ignores the tags because they
Turns on bold print and off are not defined
XML Introduction
XML Document Structure
An XML document consists of a prolog and elements.
The prolog indicates the version of xml being applied to the document and the
language set used. <?xml version="1.0" encoding="UTF-8"?>
The data within an XML document is structured into elements. The elements
are structured into a hierarchy. <root>
<child>
<subchild>.....</subchild>
</child>
</root>
XML Element Rules
<!-- This is a comment --> <?xml version = "1.0" encoding = "UTF-8" ?>
<!--Students grades are uploaded by months-->
<class_list>
<student>
<name>Anne</name>
<grade>A</grade>
</student>
</class_list>
Procedures
• A procedure contains a block of common code that can be called from with the main
body of a program
• A procedure may use input parameters
• It doesn’t need to be assigned to a variable. Hence there is no return value.
Structure
Private/Public Sub ProcedureName( byVal/byRef parameters as datatype)
End Sub
Example Private Sub proClearForm()
txtGross.Text = ""
txtHours.Text = ""
txtNetPay.Text = ""
txtRate.Text = ""
txtTax.Text = ""
End Sub
Declaring a Procedures
Structure
Private/Public Sub ProcedureName( byVal parameters as datatype)
End Sub
Parameters refers to a list of variables the procedure requires
during it’s execution
proHideShowButtons(false)
Private Sub proHideShowButtons(byval parState as boolean)
btnPrevious.visible = false parState = false
btnNext.visible = false
btnSave.visible = False
btnCancel.visible = false
End Sub
Procedure Examples
varState = true
proHideShowButtons(varState)
• Existence
• that all required fields have a value.
• Type
• that an incoming value is the right data type
(ie. numeric, date, etc.).
• Range
• that an input value is within the set of legal values.
• Length
• that an input string has the correct number of characters.
• Format
• that an input string matches the formatting pattern expected.
• Cross-field
• that values in two or more fields are consistent.
Errors that can occur in
programming
•Syntax
•Logical
•Run Time