0% found this document useful (0 votes)
3 views3 pages

Array

The document explains how to create and access arrays in Visual Basic, particularly in the context of evaluating exam grades for 30 students. It outlines a program that reads student names and scores from a text file, computes the average score, and displays the names of students who scored above average. The provided code snippet demonstrates the process of reading data and processing it using arrays.

Uploaded by

Haadi Hanim
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Array

The document explains how to create and access arrays in Visual Basic, particularly in the context of evaluating exam grades for 30 students. It outlines a program that reads student names and scores from a text file, computes the average score, and displays the names of students who scored above average. The provided code snippet demonstrates the process of reading data and processing it using arrays.

Uploaded by

Haadi Hanim
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Creating and Accessing Arrays

A variable (or simple variable) is a name to which Visual Basic can assign a single value. An
array
variable is a collection of simple variables of the same type to which Visual Basic can efficiently
assign
a list of values.
Consider the following situation: Suppose that you want to evaluate the exam grades for 30
students.
Not only do you want to compute the average score, but you also want to display the names of
the
students whose scores are above average. You might place the 30 pairs of student names and
scores in a
text file and run the program outlined:
Private Sub btnDisplay_Click(...) Handles [Link]
Dim student1 As String, score1 As Double
Dim student2 As String, score2 As Double
Dim student3 As String, score3 As Double
.
.
Dim student30 As String, score30 As Double
'Analyze exam grades
Dim sr As [Link] = [Link]("[Link]")
student1 = [Link]
score1 = CDbl([Link])
student2 = [Link]
score2 = CDbl([Link])
student30 = [Link]
score30 = CDbl([Link])
[Link]()
'Compute the average grade
'Display names of above average students
End sub
For i As Integer = 1 To 30
studenti = [Link]
scorei = CDbl([Link])
Next
Next

End Sub

End Module

You might also like