Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computing Dr. Nadeem A Khan. Lecture 25-26.

Similar presentations


Presentation on theme: "Introduction to Computing Dr. Nadeem A Khan. Lecture 25-26."— Presentation transcript:

1 Introduction to Computing Dr. Nadeem A Khan

2 Lecture 25-26

3 Chapter 7: Array Variables (Arrays)

4 ► Array:  A list of values can be assigned  Collection of variables of the same type Array Variables (Arrays)

5 ► Array Declaration: Dim arrayName (1 to n) As varType e.g: Dim names(1 To 3) as Strings Dim scores(1 To 10) as Single Array Variables (Arrays)

6 ► Value assignment: Dim names(1 To 3) as Strings Let names(1)=“Aslam” Let names(2)=“Khalid” Let names(3)=“Akbar” Picture1.Print names(3), names(2),names(1) Array Variables (Arrays)

7 ► What is what? Dim scores(1 To 3) as Single scores( ): name of the array scores(1): first element scores(2): second element scores(3): third element 1, 2, 3: subscripts Array Variables (Arrays)

8 ► What are the ranges or dimensions? Dim scores(1 To 3) as Single Dim names(1 To 10) as String Array Variables (Arrays)

9 Debugging Tools

10 Sub Command1_Click ( ) Dim num As Integer, counter As Integer Let counter=1 Do While counter<=4 Let num=1 Let num=1 Do While num<=3 Debug.Print num; Let num=num+1 Loop Let counter=counter+1 Debug.PrintLoop End Sub Debugging Tools: Example 1

11 ► The result: 1 2 3 Debugging Tools: Example 1

12 ► Reverses the input string Sub Command1_Click ( ) Picture1.Cls Debug.Print Reverse$((Text1.Text)) End Sub Debugging Tools: Example 2

13 Function Reverse$ (info As String) Dim m As Integer, j As Integer, temp As String Let temp = “” For j = Len(info) To 1 Step -1 Let temp = temp + Mid$(info, j, 1) Next Reverse$ = temp End Function Debugging Tools: Example 2

14 ► Break points ► Single Step Execution  Step Into (F8)  Step Over (Shift+F8)  Step Out (Ctl+Shift+F8) ► Watching Variables  Immediate Window  Watch Window  Local Window Debugging Tools:

15 ► Debug Object  Debug.Print  Debug.Assert Debugging Tools:

16 End


Download ppt "Introduction to Computing Dr. Nadeem A Khan. Lecture 25-26."

Similar presentations


Ads by Google