VB题“判断三个数中最大的数”其中的问题

来源:百度知道 编辑:UC知道 时间:2024/06/17 12:24:26
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single
Dim strtemp As String
a = InputBox("请输入第一个数:")
b = InputBox("请输入第二个数:")
c = InputBox("请输入第三个数:")

strtemp = a & "," & b & "," & c
strtemp = strtemp & "三个数中最大的数:"

If a > b And a > c Then
strtemp = strtemp & a
End If
If b > a And b > c Then
strtemp = strtemp & b
End If
If c > a And c > b Then
strtemp = strtemp & c
End If
Label1.Caption = strtemp
end sub

其中有“&”符号是什么意思,可以有什么简单的方法代替吗???

Dim a As Single, b As Single, c As Single
Dim strtemp As String
'以上定义变量类型

a = InputBox("请输入第一个数:")
b = InputBox("请输入第二个数:")
c = InputBox("请输入第三个数:")
'提示3个输入框,并分别将3个输入的数字分配给 a b c
'假如输入的是 1 2 3

strtemp = a & "," & b & "," & c
'这时,strtemp的内容就是 “1,2,3"

strtemp = strtemp & "三个数中最大的数:"
'这时,strtemp的内容就是 “1,2,3三个数中最大的数:”

If a > b And a > c Then
strtemp = strtemp & a
End If
'如果条件 a大于b 并且 a大于c那么 strtemp的内容是
' 1,2,3三个数中最大的数:1

If b > a And b > c Then
strtemp = strtemp & b
End If

'如果条件 b大于a 并且 b大于c那么 strtemp的内容是
' 1,2,3三个数中最大的数:2

If c > a And c > b Then
strtemp = strtemp & c
End If

'如果条件 c大于a 并且 c大于b那么 strtemp的内容是
' 1,2,3三个数中最大的数:3

Label1.Caption = strtemp
'将 strtemp 的内容赋值给la