home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH7 / 7-1-4.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-10-11  |  2.3 KB  |  75 lines

  1. VERSION 5.00
  2. Begin VB.Form frm7_1_4 
  3.    Caption         =   "Exam Analysis"
  4.    ClientHeight    =   2028
  5.    ClientLeft      =   2856
  6.    ClientTop       =   1512
  7.    ClientWidth     =   3264
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   7.8
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   2028
  20.    ScaleWidth      =   3264
  21.    Begin VB.PictureBox picTopStudents 
  22.       Height          =   1095
  23.       Left            =   120
  24.       ScaleHeight     =   1044
  25.       ScaleWidth      =   2964
  26.       TabIndex        =   1
  27.       Top             =   840
  28.       Width           =   3015
  29.    End
  30.    Begin VB.CommandButton cmdShow 
  31.       Caption         =   "Show Above-Average Students"
  32.       Height          =   495
  33.       Left            =   120
  34.       TabIndex        =   0
  35.       Top             =   120
  36.       Width           =   3015
  37.    End
  38. Attribute VB_Name = "frm7_1_4"
  39. Attribute VB_GlobalNameSpace = False
  40. Attribute VB_Creatable = False
  41. Attribute VB_PredeclaredId = True
  42. Attribute VB_Exposed = False
  43. Private Sub cmdShow_Click()
  44.   Dim numStudents As Integer, nTemp As String, sTemp As Integer
  45.   Dim student As Integer, total As Integer, average As Single
  46.   'Determine amount of data to be processed
  47.   numStudents = 0
  48.   Open App.Path & "\SCORES.TXT" For Input As #1
  49.   Do While Not EOF(1)
  50.     Input #1, nTemp, sTemp
  51.     numStudents = numStudents + 1
  52.   Loop
  53.   Close #1
  54.   'Create arrays for names and scores
  55.   ReDim nom(1 To numStudents) As String, score(1 To numStudents) As Integer
  56.   Open App.Path & "\SCORES.TXT" For Input As #1
  57.   For student = 1 To numStudents
  58.     Input #1, nom(student), score(student)
  59.   Next student
  60.   Close #1
  61.   'Analyze exam scores
  62.   total = 0
  63.   For student = 1 To numStudents
  64.     total = total + score(student)
  65.   Next student
  66.   average = total / numStudents
  67.   'Display all names with above-average grades
  68.   picTopStudents.Cls
  69.   For student = 1 To numStudents
  70.     If score(student) > average Then
  71.         picTopStudents.Print nom(student)
  72.     End If
  73.   Next student
  74. End Sub
  75.