作业帮 > 综合 > 作业

VB比较三个数大小 哪个最大就点哪个

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/17 08:18:56
VB比较三个数大小 哪个最大就点哪个
Option Explicit
Private Sub Form_Load()
Dim a As Long, b As Long, c As Long
a = InputBox("请输入第1个数:", "输入")
b = InputBox("请输入第2个数:", "输入")
c = InputBox("请输入第3个数:", "输入")
Dim Max As Long
Max = a
If b > a Then
Max = b
End If
If c > b Then
Max = c
End If
MsgBox "其中:" & Max & "最大"
End Sub
再问: Private Sub Option1_Click(Index As Integer) Dim Max As Long Max = Z If Z < Y Then Max = Y ElseIf Y < X Then Max = X MsgBox " 猜对了" Else MsgBox "猜错了" End If End Sub 为什么不对?
再答: Option Explicit

Private Sub Option1_Click(Index As Integer)
Dim Max As Long
Max = Val(Option1(0).Caption)
If Val(Option1(1).Caption) > Max Then
    Max = Val(Option1(1).Caption)
End If
If Val(Option1(2).Caption) > Max Then
    Max = Val(Option1(2).Caption)
End If
If Option1(Index).Caption = Max Then
    MsgBox "猜对了!"
Else
    MsgBox "猜错了"
End If
End Sub
再问: If Option1(Index).Caption = Max Then 怎么要调试
再答: 什么意思,什么怎么调试?要调试什么东西?