View Full Version : Help with selection sort program

11-03-2004, 04:55 PM
Ok, so here's the deal. I'm sitting in VB class right now, and I desperately need a program to take in students names from a database, sort them via selection sort and print them out into a list box. My teacher is on crack or something and will not explain anything to us, and so I am here.

Here is the code I have so far (I'm sure it makes no sense to you, but please try Lol)

Dim sr As IO.StreamReader = IO.File.OpenText("S:/data.txt")
Dim grade(25) As String
Dim test1(25), test2(25), average(25) As Double
Dim L, R, i, a(), j, SMALL, temp As Long
Dim studentName(25) As String

Private Sub cmdCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCompute.Click

For i = L To R - 2


For j = i + 1 To R
If studentName(a(j)) < studentName(a(SMALL)) Then
End If
Next j

temp = a(i)
a(i) = a(SMALL)
a(SMALL) = temp
Next i

For i = 0 To R
average(i) = test1(i) + test2(i)

studentName(i) = sr.ReadLine
test1(i) = CDbl(sr.ReadLine)
test2(i) = CDbl(sr.ReadLine)

With lstResults.Items
End With


Select Case (grade(j))
Case Is >= 90
grade(j) = "A"
Case Is >= 80
grade(j) = "B"
Case Is >= 70
grade(j) = "C"
Case Is >= 60
grade(j) = "D"
Case Is >= 0
grade(j) = "F"
End Select


End Sub

I am way behind and really don't know what I'm doing. Any help would be appreciated. Ask if you need any clarification on anything.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum