VB编程题。。各位大神帮帮忙。。
设计包含姓名、数学、英语、电子等四个文本框的窗体作为数据输入界面,输入5名学生的数据并存入数组中,然后在另一个输出窗体中按照数学,英语。电子三门课程总分从高到低的顺序显示...
设计包含姓名、数学、英语、电子等四个文本框的窗体作为数据输入界面,输入5名学生的数据并存入数组中,然后在另一个输出窗体中按照数学,英语。电子三门课程总分从高到低的顺序显示学生的全部信息。
展开
1个回答
展开全部
Dim f(5) As String
Private Sub Command1_Click()
Static i
Dim s, ss As Integer
s = Val(Text2.Text) + Val(Text4.Text) + Val(Text3.Text)
i = i + 1
If i <= 5 Then
If s > ss And i > 1 Then
p = f(i - 1)
f(i - 1) = "姓名:" & Text1.Text & " 数学:" & Text2.Text & " English:" & Text3.Text & " 电子:" & Text4.Text
f(i) = p
Else
f(i) = "姓名:" & Text1.Text & " 数学:" & Text2.Text & " English:" & Text3.Text & " 电子:" & Text4.Text
End If
End If
ss = s
Text1.Text = ""
Text4.Text = ""
Text3.Text = ""
Text2.Text = ""
End Sub
Private Sub Command2_Click()
Dim ip As Integer
For ip = 1 To 5
Form2.Text1.Text = Form2.Text1.Text & f(ip) & vbCrLf
Next ip
Form2.Visible = True
End Sub
Private Sub Command1_Click()
Static i
Dim s, ss As Integer
s = Val(Text2.Text) + Val(Text4.Text) + Val(Text3.Text)
i = i + 1
If i <= 5 Then
If s > ss And i > 1 Then
p = f(i - 1)
f(i - 1) = "姓名:" & Text1.Text & " 数学:" & Text2.Text & " English:" & Text3.Text & " 电子:" & Text4.Text
f(i) = p
Else
f(i) = "姓名:" & Text1.Text & " 数学:" & Text2.Text & " English:" & Text3.Text & " 电子:" & Text4.Text
End If
End If
ss = s
Text1.Text = ""
Text4.Text = ""
Text3.Text = ""
Text2.Text = ""
End Sub
Private Sub Command2_Click()
Dim ip As Integer
For ip = 1 To 5
Form2.Text1.Text = Form2.Text1.Text & f(ip) & vbCrLf
Next ip
Form2.Visible = True
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询