Introduction to XML



CPAN 660

Lecture #2: Syntax and Structure

files are identified by the extension .aspx. The following elements can be used with :

• Directives:

• Code Blocks: …

The code inside the script tag must be declaration, which means it must be placed either in a function or a subroutine, so we can execute this code later.

• Server Controls: or

• Data binding expressions:

• Render code (inline): and

• Server Side Comments:

Storing Information in using VB syntax:

Variables are labeled memory location for storing information. as well as the other .NET languages is strongly typed. This means any variable used in the code must be declared with a specific data type. The keyword Dim is used in to declare a variable. supports 12 different types, which are: Integer, Byte, Short, Long, Single, Double, Decimal, String , Char, Date, Boolean and Object. For example:

Dim strName As String

Dim intMark As Integer

Variables can be initialized using the assignment operator, For example

strName=”John Smith”

intMark=75

You can also declare and initialize the variable in one statement as shown in the following example:

Dim strName As String =”John Smith”

Dim intMark As Integer=75

Arithmetic Operators:

|Operation |Operator |

|Addition |+ |

|Subtraction |- |

|Multiplication |* |

|Division |/ |

|Exponentiation |^ |

|Negation |- |

|Modulus |MOD |

Note:

Strings can be concatenated using &. For example:

Dim strFName As String =”John”

Dim strLName As String = “ Smith”

Dim strFullName

strFullName=strFName & “ , “ & strLName

Arrays

Arrays are used to store a sequence of items of the same data type. For example, the following statement declares an array of size 6:

Dim intMarks(5) As Integer

Then each element must be initialized using the assignment operator:

intMarks(0)= 60

intMarks(1)= 78

intMarks(2)= 70

intMarks(3)= 86

intMarks(4)= 96

intMarks(5)= 69

Each element in the array is accessed via a zero based integer value called index. For the above example, the first item in the array is accessed by the index of zero:

also supports multi-dimensional arrays. The following example shows how to create a two dimensional array of 3 rows and 3 columns:

Dim strArray(2,2) As Integer

strArray(0,0)=”value1”

strArray(0,1)=”value2”

strArray(0,2)=”value3”

strArray(1,0)=”value4”

strArray(1,1)=”value5”

strArray(1,2)=”value6”

strArray(2,0)=”value7”

strArray(2,1)=”value8”

strArray(2,2)=”value9”

Constants

A Constant is a labelled memory location to store constant data. The keyword Const is used in to declare a constant. For example:

Const TAX=0.015

Relational (Comparison) Operators

|Operation |Operator |

|Equality |= |

|Inequality | |

|Less than |< |

|Less than or equal to | |

|Greater than or equal to |>= |

Logical Operators

• NOT

• AND

• OR

Decision making:

• If … Then Structure: For example:

If intCount =10 Then

‘ do something

End If

• If … Then … Else Structure: For example:

If intCount =10 Then

‘ do something

Else

‘ do something else

End If

• If .. Then .. ElseIf Structure: For example

If intCount =1 Then

‘ take action 1

ElseIf intCount=2 Then

‘ take action 2

Else

‘ take other action

End If

• Select Case Structure: For example:

Select Case answer

Case “yes”

‘Take action 1

Case “no”

‘ Take action 2

Case Else

‘ Take optional default action

End Select

Iteration :

• For .. Next Structure

Used when the number of iterations is known in advance. For example

For intCount= 0 To 10

‘ do something

Next intCount

• Do While Structure

Used to loop unknown number of times, as long as the specified condition is true. For example:

Dim intCount As Integer = 0

Do While intCount ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download