Dim a(1 To 10) As Integer, b(1 To 10) As Integer, c(1 To 10) As Integer
Private Sub Command1_Click() '重置
Dim i As Integer
Randomize
For i = 1 To 10
a(i) = Int(Rnd * 89) + 11
b(i) = Int(Rnd * 89) + 11
c(i) = Int(Rnd * 89) + 11
Next
End Sub
Private Sub Command2_Click() '求最大者
Dim Maxa As Integer, Maxb As Integer, Maxc As Integer
Dim i As Integer
For i = 1 To 10
If a(i) >Maxa Then Maxa = a(i)
If b(i) >Maxa Then Maxb = b(i)
If c(i) >Maxa Then Maxc = c(i)
Next
MsgBox "第1组的最大值是:" &Maxa &vbNewLine &"第2组的最大值是:" &Maxb &vbNewLine &"第3组的最大值是:" &Maxc
End Sub
Private Sub Command1_Click()Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim max As Integer
max = 0
a = InputBox("请输入第一个数字")
b = InputBox("请输入第二个数字")
c = InputBox("请输入第三个数字")
If a > max Then
max = a
End If
If b > max Then
max = b
End If
If c > max Then
max = c
End If
MsgBox ("最大数字是" & max)
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)