永发信息网

vb里面判断啊,a,b,c,三个数从大到小显示在label1里面,写了程序但是运行不了,给看那里写错了

答案:3  悬赏:20  手机版
解决时间 2021-03-22 22:38
  • 提问者网友:玫瑰园
  • 2021-03-22 00:42
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single, t As Single, p As String
p = ""
a = Val(InputBox("请输入第一个数值", "a的值", "0"))
b = Val(InputBox("请输入第二个数值", "b的值", "0"))
c = Val(InputBox("请输入第三个数值", "c的值", "0"))
p =p&a&","&b&","&c&"从小到大的顺序是"
If a < b Then t = a: a = b: b = t
End If
If a < c Then t = a: a = c: c = t
End If
If b < c Then t = b: b = c: c = t
End If
label1.Caption =p&a&","&b&","&c
End Sub
最佳答案
  • 五星知识达人网友:忘川信使
  • 2021-03-22 01:31
帮你改好了 你的代码大体上没错 就是if语句 then后面的语句没有和then分行不用加上end if
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single, t As Single, p As String
p = ""
a = Val(InputBox("请输入第一个数值", "a的值", "0"))
b = Val(InputBox("请输入第二个数值", "b的值", "0"))
c = Val(InputBox("请输入第三个数值", "c的值", "0"))
p = p & a & b & c & "从小到大的顺序是"
If a < b Then t = a: a = b: b = t
If a < c Then t = a: a = c: c = t
If b < c Then t = b: b = c: c = t
lable1.caption=p & a & "," & b & "," & c
End Sub
全部回答
  • 1楼网友:蕴藏春秋
  • 2021-03-22 03:18
& 的前后一定要各留出一个空格。 p =p&a&","&b&","&c&"从小到大的顺序是" 应为 p =p & a & "," & b & "," & c & "从大到小的顺序是" 后面的 label1.Caption =p&a&","&b&","&c 应为 label1.Caption =p & a & "," & b & "," & c
  • 2楼网友:走死在岁月里
  • 2021-03-22 02:11
Private Sub Command1_Click() Dim a As Single, b As Single, c As Single, t As Single, p As String p = "" a = Val(InputBox("请输入第一个数值", "a的值", "0")) b = Val(InputBox("请输入第二个数值", "b的值", "0")) c = Val(InputBox("请输入第三个数值", "c的值", "0")) p = "a," & "b," & "c," & "从大到小的顺序是" Print p If a < b Then t = a: a = b: b = t End If If a < c Then t = a: a = c: c = t End If If b < c Then t = b: b = c: c = t End If Label1.Caption = p & a & "," & b & "," & c End Sub 是不是&符号和前后没有空格呢
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯