这次希望可以把做好的程序直接发到我的邮箱。所以因为难度比较大分当然会高的。
要求:可以输入任意多学生的姓名以及每个学生5门功课(语数外理化)的成绩,输入完毕开始统计后程序可以列出表格显示出所输入的每位同学的每门功课在全部输入同学中的名次,以及总分名次。界面的话随意,一个窗口多个窗口都可以,但是请一定要用数组(貌似不用也是不可能的)。谢谢。
我的邮箱:[email protected]
不胜感激,以上
cxh20080808谢谢你,但是那个LISTVIEW控件不会用TAT,能不能麻烦大人修改一下,改成用TEXTBOX之类的控件,真的麻烦了。然后那个随机生成可以不需要。修改好的话能不能无理地要求把整个程序压缩发过来呢,因为直接在程序里看代码会比较方便,知道哪个对应哪个。如果愿意帮忙弄好的话,我可以把分加到200.知道这个程序很麻烦,所以真的拜托了。
程序已发送
Label1()数组0-5,Text1()数组0-5,四个命令按钮,一个ListView1(注意添加部件)。
Dim s() As Double, sName() As String, NN As Integer
Private Sub Command3_Click()
Dim i As Integer, j As Integer
Command4_Click '初始化数组
For i = 1 To 50
If NN = UBound(s, 2) Then
ReDim Preserve s(12, NN + 10), sName(NN + 10)
End If
NN = NN + 1
s(0, NN) = NN
Set li = ListView1.ListItems.Add(, , NN)
sName(NN) = "姓名" & i
With li.ListSubItems
.Add , , sName(NN)
For j = 1 To 5
Randomize
s(j * 2 - 1, NN) = Int(Rnd * 61) + 40 '分数
s(11, NN) = s(11, NN) + s(j * 2 - 1, NN)
.Add , , s(j * 2 - 1, NN)
.Add , , " "
Next j
.Add , , s(11, NN)
.Add , , " "
End With
Next i
Label1(6).Caption = "准备输入第" & i & "个人"
If NN > 0 Then Command2.Enabled = True
End Sub
Private Sub Command1_Click()
Dim i As Integer, li As ListItem
For i = 0 To 5
If Len(Trim(Text1(i).Text)) = 0 Then
MsgBox Label1(i).Caption & "没有输入!", , "输入错误"
Exit Sub
End If
Next i
If NN = UBound(s, 2) Then
ReDim Preserve s(12, NN + 10), sName(NN + 10)
End If
NN = NN + 1
s(0, NN) = NN
Set li = ListView1.ListItems.Add(, , NN)
sName(NN) = Trim(Text1(0).Text)
Text1(0).Text = ""
With li.ListSubItems
.Add , , sName(NN)
For i = 1 To 5
s(i * 2 - 1, NN) = Val(Text1(i).Text) '分数
s(11, NN) = s(11, NN) + s(i * 2 - 1, NN)
.Add , , s(i * 2 - 1, NN)
.Add , , " "
Text1(i).Text = ""
Next i
.Add , , s(11, NN)
.Add , , " "
End With
If NN > 0 Then Command2.Enabled = True
Label2.Caption = "准备输入第" & NN + 1 & "个人"
End Sub
Private Sub Command2_Click()
Dim i As Integer, j As Integer, li As ListItem, k As Integer, m As Integer, n As Integer
Dim f() As Double
ReDim f(NN)
For i = 1 To 11 Step 2
For j = 1 To NN
s(i + 1, j) = 1
For k = 1 To NN
If s(i, j) < s(i, k) Then s(i + 1, j) = s(i + 1, j) + 1
Next k
Next j
For j = 1 To NN
ListView1.ListItems(j).ListSubItems(i + 2) = s(i + 1, j) '排名
Next j
Next i
End Sub
Private Sub Command4_Click()
NN = 0
Erase s, sName
ReDim s(12, 30), sName(30)
ListView1.ListItems.Clear
Command2.Enabled = False
Label1(6).Caption = "准备输入第" & NN + 1 & "个人"
End Sub
Private Sub Form_Load()
Dim i As Integer, a
a = Array("姓名", "语文", "数学", "英语", "物理", "化学")
For i = 0 To 5
Label1(i).Caption = a(i)
Next i
Me.Caption = "成绩统计系统"
Command1.Caption = "保存"
Command2.Caption = "统计"
Command3.Caption = "随机生成50名学生"
Command4.Caption = "清除"
With ListView1
.GridLines = True
.FullRowSelect = True
.LabelEdit = lvwManual
With .ColumnHeaders
.Add , , "学号", 600
.Add , , "姓名", 900
For i = 1 To 5
.Add , , Label1(i).Caption, 600
.Add , , "名次", 600
Next i
.Add , , "总分", 600
.Add , , "名次", 600
End With
End With
Command4_Click '初始化数组
Text1(0).IMEMode = 1 '打开输入法
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(i).IMEMode = IIf(Index, 2, 1) '打开或关闭输入法
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then Text1(IIf(Index = 5, 0, Index + 1)).SetFocus '回车到下一个输入框
If Index Then
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 46 Then KeyAscii = 0 '只接受数字和小数点
End If
End Sub