'这题目对初学者,其实很有难度,运行效果如下
Private Sub command1_click()
Dim X As String
Dim brr
Dim a As Long
Dim b As Long
Dim c As Long
X = InputBox("请输入3个整数(以英文逗号分隔):", "求最大数", "例如:3,344,51", 1000, 1000)
brr = Split(X, ",")
If UBound(brr) > 2 Then
MsgBox "输入数字多余3个,请重新输入!", , "提醒"
End '退出
End If
If UBound(brr) < 2 Then
MsgBox "输入数字少余3个,请重新输入!", , "提醒"
End '退出
End If
a = brr(0)
b = brr(1)
c = brr(2)
MsgBox "这三个数的最大数是" & Max(Max(a, b), c), , "最大数显示"
End Sub
Function Max(n1 As Long, n2 As Long) As Long
Max = IIf(n1 > n2, n1, n2)
End Function
Private Sub Command1_Click()
a = Val(InputBox("A="))
b = Val(InputBox("B="))
c = Val(InputBox("C="))
Max = IIf(a > b, a, b)
If c > Max Then Max = c
MsgBox "最大数=" & Max
End Sub
Private Sub Form_Load()
Form1.Caption = "最大数"
End Sub