然后求平均分,按分数排序显示出来!并可以查询原始分数
老师叫我6月初交给他
平时没认真学,到有用的时候就抓瞎了!实在是惭愧啊
那位有的话发到我邮箱来 liaohaoqiao@163.com 感激不尽~~!!!
刚才忘记发程序上来。。。。。。
[此贴子已经被作者于2006-5-26 16:10:32编辑过]
[此贴子已经被作者于2006-5-26 16:10:32编辑过]
我搞了一段时间,其中图书馆跑了N次,网上也找了很多资料
但是!!基础太烂啊,好不容易搞了点东西出来,还是朋友帮了大忙
有写功能还无法实现,希望大家伸出援手帮帮我~谢谢!!!!!
现在最主要的问题是无法连接数据库,其他还有许多小问题
还有些我没发现的,请帮我完善他,感激不尽~!! 程序发到一楼上去了!!!
[CODE]
Dim temp As Single
Dim Min As Single '用于比较哪个数字小的变量
Dim Max As Single '用于比较哪个数字大的变量
Option Explicit
Private Sub bianji_Click()
End Sub
Private Sub Command1_Click()
Dim a(9) As Single
If Text5.Text = "" Then '判断选手姓名是否为空
MsgBox "请先输入选手姓名", vbOKOnly
Text5.SetFocus '将光标置于选手姓名输入框,方便输入
End If
If Text1(0).Text = "" Then
MsgBox " 请输入内容 "
Text1(0).SetFocus
ElseIf Text1(0).Text < 1 Or Text1(0).Text > 10 Then
MsgBox "只能输入1-10"
Text1(0).SetFocus
ElseIf Text1(1).Text = "" Then
MsgBox " 请输入内容 "
Text1(1).SetFocus
ElseIf Text1(1).Text < 1 Or Text1(1).Text > 10 Then
MsgBox "只能输入1-10"
Text1(1).SetFocus
ElseIf Text1(2).Text = "" Then
MsgBox " 请输入内容 "
Text1(2).SetFocus
ElseIf Text1(2).Text < 1 Or Text1(2).Text > 10 Then
MsgBox "只能输入1-10"
Text1(2).SetFocus
ElseIf Text1(3).Text = "" Then
MsgBox " 请输入内容 "
Text1(3).SetFocus
ElseIf Text1(3).Text < 1 Or Text1(3).Text > 10 Then
MsgBox "只能输入1-10"
Text1(3).SetFocus
ElseIf Text1(4).Text = "" Then
MsgBox " 请输入内容 "
Text1(4).SetFocus
ElseIf Text1(4).Text < 1 Or Text1(4).Text > 10 Then
MsgBox "只能输入1-10"
Text1(4).SetFocus
ElseIf Text1(5).Text = "" Then
MsgBox " 请输入内容 "
Text1(5).SetFocus
ElseIf Text1(5).Text < 1 Or Text1(5).Text > 10 Then
MsgBox "只能输入1-10"
Text1(5).SetFocus
ElseIf Text1(6).Text = "" Then
MsgBox " 请输入内容 "
Text1(6).SetFocus
ElseIf Text1(6).Text < 1 Or Text1(6).Text > 10 Then
MsgBox "只能输入1-10"
Text1(6).SetFocus
ElseIf Text1(7).Text = "" Then
MsgBox " 请输入内容 "
Text1(7).SetFocus
ElseIf Text1(7).Text < 1 Or Text1(7).Text > 10 Then
MsgBox "只能输入1-10"
Text1(7).SetFocus
ElseIf Text1(8).Text = "" Then
MsgBox " 请输入内容 "
Text1(8).SetFocus
ElseIf Text1(8).Text < 1 Or Text1(8).Text > 10 Then
MsgBox "只能输入1-10"
Text1(8).SetFocus
ElseIf Text1(9).Text = "" Then
MsgBox " 请输入内容 "
Text1(9).SetFocus
ElseIf Text1(9).Text < 1 Or Text1(9).Text > 10 Then
MsgBox "只能输入1-10"
Text1(9).SetFocus
Else
Call panduan(a)
End If
' Call panduan(a) '引用panduan程序段
End Sub
Private Sub panduan(a() As Single)
Dim Average As Single, Sum As Single '用于存放平均值average、和sum
Dim P_max As Integer, P_min As Integer '记住位置
Dim i As Integer
Max = Text1(0) '将TEXT1(0)的值赋于MAX
Min = Text1(0) '将TEXT1(0)的值赋予MIN
For i = 0 To 9 '开始比较输入的数字大小
If Text1(i) > Max Then '循环比较哪个数字大,将比较大的值放到P_max中,再将这个数字与下个数字比较,最后将最大的值放到MAX中
Max = Text1(i)
P_max = i
ElseIf Text1(i) < Min Then '循环比较比较那个数字小,将最小的值放到P_min中,再将这个数字与下个数字比较,最后将最小的值放到MIN中
Min = Text1(i)
P_min = i
End If
Sum = Sum + Text1(i) '所有评委的数字和
Next i
Average = (Sum - Max - Min) / 8 '减去最高分和最低分,然后求平均值
Text2.Text = Format(Max, "##.00") '输出最大值,保留两位小数
Text4.Text = Format(Min, "##.00") '输出最小值,保留两位小数
Text3.Text = Format(Average, "##.00") '输出平均值,保留两位小数
End Sub
Private Sub Command2_Click()
'按下“清空”按钮,清空所有的TEXT内的内容
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
Text1(3).Text = ""
Text1(4).Text = ""
Text1(5).Text = ""
Text1(6).Text = ""
Text1(7).Text = ""
Text1(8).Text = ""
Text1(9).Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Command3_Click()
Load Form2
Form2.Show
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
'Form1.Height = 600 * 15: Form1.Width = 800 * 15
'Form1.Left = 100 * 15: Form1.Top = 100 * 15
'Form1.Scale (0, 0)-(800, 600)
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then 'keyascii=13就是回车键,如果按下了回车键,就执行“开始评分”
Call Command1_Click
End If
Select Case KeyAscii 'keyascii=8 就是←键,如果按下这个键,继续执行
Case 8
Case 46
Case 48 To 57: 'keyascii 48-57 就是数字键0-9 ,按下0-9继续执行
Case Else: '如果没按上面的全部按键,则弹出窗口
MsgBox "请输入数字", vbOKOnly
KeyAscii = 0
End Select
'If KeyAscii < 48 Or KeyAscii > 57 Then '只能输入数字键判断
'ASCII码的46-57对应键盘的键是: “.” “/” “0-9”
'不知道退后键对应的ASCII码的是什么
'MsgBox "请输入数字!"
'KeyAscii = 0
'End If
End Sub
Private Sub tuichu_Click()
End
End Sub
[此贴子已经被作者于2006-5-26 16:11:40编辑过]