求一个VB简单程序代码
求一个VB程序代码,要求能输入60个学生成绩(用inputbox),并统计其平均分、最高分、最低分和优秀及格人数。越简单越好,不用太复杂,有点小问题也没关系!谢谢了!...
求一个VB程序代码,要求能输入60个学生成绩(用inputbox),并统计其平均分、最高分、最低分和优秀及格人数。越简单越好,不用太复杂,有点小问题也没关系!谢谢了!
展开
展开全部
以下程序可以运行,添加5个文本框用于显示,一个按钮。
Private Sub Command1_Click()
Dim val(1 To 60) As Integer
Dim pass%, good%, i%, j%, temp%, sum%
'输入60个学生的成绩
For i = 1 To 60
val(i) = InputBox("输入第" & i & "个学生的成绩:")
'计算总成绩
sum = sum + val(i)
'计算及格(大于60分)人数和优秀(大于90分)人数
If val(i) > 59 Then pass = pass + 1
If val(i) > 89 Then good = good + 1
Next i
'对60个学生成绩按从小到大排序
For i = 1 To 60
For j = i + 1 To 60
If val(i) > val(j) Then
temp = val(i): val(i) = val(j): val(j) = temp
End If
Next j
Next i
Text1 = val(1) '最低分
Text2 = val(60) '最高分
Text3 = sum / 60 '平均分
Text4 = pass '及格人数
Text5 = good '优秀人数
End Sub
请楼主参考
Private Sub Command1_Click()
Dim val(1 To 60) As Integer
Dim pass%, good%, i%, j%, temp%, sum%
'输入60个学生的成绩
For i = 1 To 60
val(i) = InputBox("输入第" & i & "个学生的成绩:")
'计算总成绩
sum = sum + val(i)
'计算及格(大于60分)人数和优秀(大于90分)人数
If val(i) > 59 Then pass = pass + 1
If val(i) > 89 Then good = good + 1
Next i
'对60个学生成绩按从小到大排序
For i = 1 To 60
For j = i + 1 To 60
If val(i) > val(j) Then
temp = val(i): val(i) = val(j): val(j) = temp
End If
Next j
Next i
Text1 = val(1) '最低分
Text2 = val(60) '最高分
Text3 = sum / 60 '平均分
Text4 = pass '及格人数
Text5 = good '优秀人数
End Sub
请楼主参考
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
展开全部
Dim t As Integer
Dim max As Integer
Dim min As Integer
Dim pass As Single
Dim exce As Single
max = 0
min = 100
n = Val(InputBox("请输入学生人数"))
For i = 1 To n
s = Val(InputBox("请输入第" & i & "个学生的成绩"))
If s > max Then max = max + 1
If s < min Then min = min + 1
If s >= 60 Then pass = pass + 1
If s > 85 Then exce = exce + 1
t = t + s
Next i
Print "均 分:" & t / n
Print "最高分:" & max
Print "最低分:" & min
Print "及格数:" & pass
Print "优秀数:" & exce
Dim max As Integer
Dim min As Integer
Dim pass As Single
Dim exce As Single
max = 0
min = 100
n = Val(InputBox("请输入学生人数"))
For i = 1 To n
s = Val(InputBox("请输入第" & i & "个学生的成绩"))
If s > max Then max = max + 1
If s < min Then min = min + 1
If s >= 60 Then pass = pass + 1
If s > 85 Then exce = exce + 1
t = t + s
Next i
Print "均 分:" & t / n
Print "最高分:" & max
Print "最低分:" & min
Print "及格数:" & pass
Print "优秀数:" & exce
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private Sub form_load()
Form1.AutoRedraw = True
End Sub
Private Sub command1_click()
Const N = 60 'N是学生人数
Dim C(60) As Single
Dim max As Single, min As Single
Dim I As Integer, Yx As Byte, Jg As Byte
Dim Pj As Single
Dim St As String
max = 0
min = 100
Jg = 0
Yx = 0
For I = 1 To N
St = InputBox("请输入第" & I & "个学生的成绩(回车退出,<0无效)", "输入")
If St = "" Then Exit Sub
If Val(St) < 0 Then
I = I - 1
Else
C(I) = Val(St)
If C(I) > max Then max = C(I)
If C(I) < min Then min = C(I)
If C(I) >= 60 Then Jg = Jg + 1
If C(I) >= 90 Then Yx = Yx + 1
Pj = Pj + C(I)
End If
Next I
Pj = Pj / 60
Print "平均分:"; Pj
Print "最高分:"; max
Print "最低分:"; min
Print "及格人数:"; Jg
Print "优秀人数:"; Yx
End Sub
Private Sub form_load()
Form1.AutoRedraw = True
End Sub
Private Sub command1_click()
Const N = 60 'N是学生人数
Dim C(60) As Single
Dim max As Single, min As Single
Dim I As Integer, Yx As Byte, Jg As Byte
Dim Pj As Single
Dim St As String
max = 0
min = 100
Jg = 0
Yx = 0
For I = 1 To N
St = InputBox("请输入第" & I & "个学生的成绩(回车退出,<0无效)", "输入")
If St = "" Then Exit Sub
If Val(St) < 0 Then
I = I - 1
Else
C(I) = Val(St)
If C(I) > max Then max = C(I)
If C(I) < min Then min = C(I)
If C(I) >= 60 Then Jg = Jg + 1
If C(I) >= 90 Then Yx = Yx + 1
Pj = Pj + C(I)
End If
Next I
Pj = Pj / 60
Print "平均分:"; Pj
Print "最高分:"; max
Print "最低分:"; min
Print "及格人数:"; Jg
Print "优秀人数:"; Yx
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用Excel马上搞定,何必呢!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private sub command1_click()
command1.enabled = false
command2.enabled = true
label1.visible = true
form1.caption = "单击“隐藏”按钮隐藏文字"
end sub
private sub command2_click()
command1.enabled = true
command2.enabled = false
label1.visible = false
form1.caption = "单击“显示”按钮显示文字"
end sub
private sub form_load()
label1.caption = "hello"
label1.visible = false
command1.caption = "显示"
command2.caption = "隐藏"
command2.enabled = false
form1.caption = "单击“显示”按钮显示文字"
end sub
command1.enabled = false
command2.enabled = true
label1.visible = true
form1.caption = "单击“隐藏”按钮隐藏文字"
end sub
private sub command2_click()
command1.enabled = true
command2.enabled = false
label1.visible = false
form1.caption = "单击“显示”按钮显示文字"
end sub
private sub form_load()
label1.caption = "hello"
label1.visible = false
command1.caption = "显示"
command2.caption = "隐藏"
command2.enabled = false
form1.caption = "单击“显示”按钮显示文字"
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询