VB比较三个数大小 哪个最大就点哪个
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/06/26 03:21:25
VB比较三个数大小 哪个最大就点哪个
![VB比较三个数大小 哪个最大就点哪个](/uploads/image/z/5160218-50-8.jpg?t=VB%E6%AF%94%E8%BE%83%E4%B8%89%E4%B8%AA%E6%95%B0%E5%A4%A7%E5%B0%8F+%E5%93%AA%E4%B8%AA%E6%9C%80%E5%A4%A7%E5%B0%B1%E7%82%B9%E5%93%AA%E4%B8%AA)
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 怎么要调试
再答: 什么意思,什么怎么调试?要调试什么东西?
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 怎么要调试
再答: 什么意思,什么怎么调试?要调试什么东西?