home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frm7_2_4
- Caption = "Average"
- ClientHeight = 1230
- ClientLeft = 3180
- ClientTop = 2475
- ClientWidth = 2640
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 1230
- ScaleWidth = 2640
- Begin VB.PictureBox picAverage
- Height = 255
- Left = 120
- ScaleHeight = 195
- ScaleWidth = 2355
- TabIndex = 1
- Top = 840
- Width = 2415
- End
- Begin VB.CommandButton cmdDisplay
- Caption = "Display Average"
- Height = 495
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 2415
- End
- Attribute VB_Name = "frm7_2_4"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub cmdDisplay_Click()
- 'Pass array to a Sub procedure and a Function procedure
- Dim score(1 To 10) As Integer
- Call FillArray(score())
- picAverage.Cls
- picAverage.Print "The average score is"; Sum(score()) / 10
- End Sub
- Private Sub FillArray(s() As Integer)
- 'Fill array with scores
- s(1) = 85
- s(2) = 92
- s(3) = 75
- s(4) = 68
- s(5) = 84
- s(6) = 86
- s(7) = 94
- s(8) = 74
- s(9) = 79
- s(10) = 88
- End Sub
- Private Function Sum(s() As Integer) As Integer
- Dim total As Integer, index As Integer
- 'Add up scores
- total = 0
- For index = 1 To 10
- total = total + s(index)
- Next index
- Sum = total
- End Function
-