VB由键盘上任意输入三个数后,找出最大数,并用消息框输出结果
Private Sub Command1_Click()Dim a As Double
Dim b As Double
Dim c As Double
a = Val(InputBox("a="))
b = Val(InputBox("b="))
c = Val(InputBox("c="))
Dim max As Double
Dim maxpos As Double
max = a
maxpos = "第一"
If max < b Then
max = b
maxpos = "第二"
End If
If max < c Then
max = c
maxpos = "第三"
End If
MsgBox "三个数是:" + CStr(a) + "、" + CStr(b) + "、" + CStr(c) + vbCr + "最大数是" + maxpos + "个:" + CStr(max)
End Sub
错误在哪里?求大神
Dim maxpos As String不是Double类型的改成String 类型的 Dim maxpos As Double 这里错误
你后面写的是 maxpos = "第一"
所以不能定义成 Double 得定义成string
页:
[1]