Solved

Sorting 10 numbers and choosing the best 6

Posted on 2002-03-04
4
179 Views
Last Modified: 2010-05-02
I have table that i created in MS aceess which has marks obtained by a student in 10 Exams, therefore I want a code that can choose the best 6 exams by the student and add their percentage and do the average of those 6 best exams.
0
Comment
Question by:Bush21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 2

Accepted Solution

by:
damienm earned 55 total points
ID: 6838650
Private Sub Command1_Click()
Dim a(9) As Integer
Dim b(9) As Integer
Dim ival As Integer
Dim avgTopSix
a(0) = 55
a(1) = 67
a(2) = 29
a(3) = 33
a(4) = 54
a(5) = 62
a(6) = 22
a(7) = 33
a(8) = 43
a(9) = 25

For j = 0 To 9
    tmpInt = 0
    For i = 0 To 9
        If a(i) >= a(ival) Then
            ival = i
        End If
       
    Next i
    b(j) = a(ival)
    a(ival) = 0
Next j
For j = 0 To 9
    If j < 6 Then
        avgTopSix = avgTopSix + b(j)
    End If
    'MsgBox b(j)
Next j
MsgBox "The average of the top 6 scores is : " & avgTopSix / 6

End Sub
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6839383
This sounds like a homework assignment, so I'll only offer the logic, not the code:

1) Put the grades into an array
2) Sort the tests, highest grade to lowest
3) Pull off the first six array elements and get their sum
4) Display the sum divided by six
0
 
LVL 1

Expert Comment

by:mammouth
ID: 6839630
'this give you the top 6 best note from access table
"select top 6 note from table order by note desc"

add your 6 note and divide by 6

and its done
0
 

Author Comment

by:Bush21
ID: 6841210
Thanks man!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 94
Help me. 3 79
IF ELSE Statement in Excel Macro VBA 16 104
VB6 - Cannot type when doing an extract from MSHFlexgrid to Excel 6 48
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question