Dim Sc(10) As Single
Dim max As Single, min As Single, s As Single, p As Single, x As Single
Dim i As Integer
s = 0
Sc(1) = Val(InputBox("请输入第1个评委的分数!"))
Do While Sc(1) < 0 Or Sc(1) > 10
Sc(1) = Val(InputBox("请输入第1个评委的分数!", "输入错误!请重新输入!"))
Loop
max = Sc(1)
min = Sc(1)
s = s + Sc(1)
For i = 2 To 10
Sc(i) = Val(InputBox("请输入第" & i & "个评委的分数!"))
Do While Sc(i) < 0 Or Sc(i) > 10
Sc(i) = Val(InputBox("请输入第" & i & "个评委的分数!", "输入错误!请重新输入!"))
Loop
s = s + Sc(i)
If Sc(i) > max Then max = Sc(i)
If Sc(i) < min Then min = Sc(i)
Next i
s = s - max - min
p = s / 8
Print "评委给分:"
Print "序号:";
For i = 1 To 10
Print Left(CStr(i) & " ", 4);
Next i
Print "得分:";
For i = 1 To 10
Print Left(CStr(Sc(i)) & " ", 4);
Next i
Print "平均分:"; p
Dim a(1 To 100) As String
Dim i As Integer, x As Integer
Const n = 3 'n的值可根据实际需要赋予不同的变量
Private Sub Command1_Click()
Timer1Enabled = True
End Sub
Private Sub Command2_Click()
Timer1Enabled = False
End Sub
Private Sub Form_Load()
Randomize '初始化随机数生成器
a(1) = "富士康" '以此将n个人的姓名保存在数组a中
a(2) = "庞麦郎"
a(3) = "非主流"
For i = 1 To n
List1AddItem a(i)
Next
Timer1Enabled = False
End Sub
Private Sub Timer1_Timer()
x = Rnd() n + 1 '产生一个[1,n]中的随机整数并存入变量x中
Label2Caption = a(x) '在标签Label2中显示下标变量a(x)的值(第x个人的姓名)
End Sub
Private Sub Command1_Click()
If IsNumeric(Text1) And Len(Text1) = 7 Then '判断输入的是否为7位数字
Randomize
a = Format(Int(Rnd 9999999 + 1), "0000000") '生成开奖号码
Label1Caption = "本期开奖号码为:" & a
For i = 1 To 7 '逐位判断是否相同,b为相同个数
If Mid(Text1, i, 1) = Mid(a, i, 1) Then
b = b + 1
End If
Next
If b = 7 Then
Label2Caption = "恭喜你中得一等奖"
ElseIf b = 6 Then
Label2Caption = "恭喜你中得二等奖"
ElseIf b = 5 Then
Label2Caption = "恭喜你中得三等奖"
'以此类推判断是否中奖
Else
Label2Caption = "很遗憾,差一点就中奖了"
End If
Else
MsgBox "请输入一个七位数字"
Exit Sub
End If
End Sub
Private Sub Command1_Click()
lap1:
n = InputBox("请输入兑奖号码(七星彩):")
If Len(n) <> 7 Or Not IsNumeric(n) Then
MsgBox "请输入正确兑奖号码"
GoTo lap1:
End If
s = "": ms = ""
k = 0: Max = 0
For i = 1 To 7
If Mid(Text1Text, i, 1) = Mid(CStr(n), i, 1) Then
k = k + 1
s = s + Mid(CStr(n), i, 1)
If k > Max Then
Max = k
ms = s
End If
Else
s = ""
k = 0
End If
Next
If Max < 2 Then st = "没有中奖"
If Max = 2 Then st = "中六等奖"
If Max = 3 Then st = "中五等奖"
If Max = 4 Then st = "中四等奖"
If Max = 5 Then st = "中三等奖"
If Max = 6 Then st = "中二等奖"
If Max = 7 Then st = "恭喜你中一等奖"
MsgBox st
End Sub
Private Sub Form_Load()
Randomize
Text1Text = ""
For i = 1 To 7
Text1Text = Text1Text & Int(Rnd 10) '产生七星彩中奖号码
Next
End Sub
Dim a(20) '如果不需要显示20个数的话,不需要数组,a(i)用X代替就可以
Dim max!, Min!, i%
Private Sub Command1_Click() '按钮单击
For i = 1 To 20
a(i) = Int(Rnd 10) + 1 '[1~10]间在随机数
s = s + a(i) '求和
If i = 1 Then '最大最小值的初值为第一个数
max = a(1): Min = a(1)
Else
If max < a(i) Then max = a(i)
If Min > a(i) Then Min = a(i)
End If
Next i
Print (s - max - Min) / 18 '求平均
End Sub
VB中添加一个按钮点击就可以了
Private Sub Command1_Click()
a = InputBox("请输入分数:")
If IsNumeric(a) And a <= 100 And a >= 0 Then
Select Case a
Case 0 To 59
dd = "E"
Case 60 To 69
dd = "D"
Case 70 To 79
dd = "C"
Case 80 To 89
dd = "B"
Case 90 To 100
dd = "A"
Case Else
dd = "成绩错误!"
End Select
MsgBox dd
Else
MsgBox "你输入的成绩非法"
End If
End Sub
以上就是关于vb歌手大赛评分程序10位评委除去一个最高分和一个最低分计算平均数(设满分为10)全部的内容,包括:vb歌手大赛评分程序10位评委除去一个最高分和一个最低分计算平均数(设满分为10)、VB中可用的抽奖程序的代码、如何用vb创建一个彩票兑奖程序 急!!!!!!!!!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)