錯誤應該不少,求大神改錯和排序
大一vb期末大作業的分工
對編號、年齡和人氣的排序,分別排序

Public Class infolist
Dim lastrecord As Integer
Dim carray(,) As String
Private Sub frmdisplay_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
FileClose(1)
End Sub
Private Sub frmdisplay_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Dim i As Integer
FileOpen(1, Application.StartupPath & "\regist.txt",
OpenMode.Random, , , Len(parti))
lastrecord = LOF(1) / Len(parti)
infolist.Items.Clear()
infolist.Items.Add("編號" & Space(7) & "姓名" & Space(7) & "性別" & Space(5) & "年齡" & Space(7) & "人氣" & Space(7) & "專業")
For i = 1 To lastrecord
FileGet(1, parti, i)
infolist.Items.Add(parti.no & Space(11 - Len(parti.no)) & parti.name & Space(11 - Len(parti.name)) & parti.sex & Space(11 - Len(parti.sex)) & parti.age & Space(11 - Len(parti.age)) & parti.vote & Space(11 - Len(parti.vote)) & parti.major)
infolist.items.Add(parti.no & parti.name & parti.sex & parti.age & parti.vote & parti.major)
Next i
End Sub
Private Sub cmdsortno_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdsortno.Click
Dim n As Integer
'Dim number(n, 1) As Single
n = LOF(1) / Len(parti)
If n = 0 Then
MsgBox("no students in the file")
Else
ReDim carray(n, 5)
Call readdata(carray, n)
Call sortdata(carray, n, 0)
Call showdata(carray, n)
End If
End Sub
Private Sub cmdsortvote_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsortvote.Click
Dim n As Integer
n = LOF(1) / Len(parti)
If n = 0 Then
MsgBox("no students in the file")
Else
ReDim Preserve carray(n, 5)
Call readdata(carray, n)
Call sortdata(carray, n, 0)
Call showdata(carray, n)
End If
End Sub
Private Shared Function items() As Object
Throw New NotImplementedException
End Function
Private Sub cmdsortage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsortage.Click
Dim n As Integer
n = LOF(1) / Len(parti)
If n = 0 Then
MsgBox("no student in the file")
Else
ReDim carray(n, 5)
Call readdata(carray, n)
Call sortdata(carray, n, 3)
Call showdata(carray, n)
End If
End Sub
Private Sub cmdback_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdback.Click
form3.hide()
form2.show()
End Sub
Private Sub ListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.Click
ListBox1.Text = ""
Dim str As String
FileOpen(1, "C:\Users\lenovo\Desktop\VB\表單\表單\選手資訊", OpenMode.Input)
Do While Not EOF(1)
str = LineInput(1)
ListBox1.Text = ListBox1.Text + str + vbCrLf
Loop
End Sub
End Class
uj5u.com熱心網友回復:

作業…………
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/57454.html
標籤:VB基礎類
