中易网

急急急!!!VB:用键盘输入3个数,求3个数按从小到大排列输出

答案:6  悬赏:50  
解决时间 2021-04-28 09:11
  • 提问者网友:斯文败类
  • 2021-04-27 16:12

最好是用选择结构     急急急!!!

最佳答案
  • 二级知识专家网友:堕落奶泡
  • 2021-04-27 17:08

使用我编的过程,自己在主函数调用即可:


 Sub FromSmallToBig(ByRef num1 As Integer, ByRef num2 As Integer, ByRef num3 As Integer)    Dim temp As Integer


    If (num1 > num2) Then    temp = num1    num1 = num2    num2 = temp    End If


    If (num1 > num3) Then    temp = num1    num1 = num3    num3 = temp    End If


    If (num2 > num3) Then    temp = num2    num2 = num3    num3 = temp    End If


    End Sub

全部回答
  • 1楼网友:猖狂的痴情人
  • 2021-04-27 19:29

Private Sub Command1_Click() Dim a As Integer, b As Integer, t As Integer a = Val(Text1.Text) b = Val(Text2.Text) t = Val(Text3.Text) If a > b Then c = 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 Text4.Text = a Text5.Text = b Text6.Text = c End Sub

和上面的都差不多   把我们两个都采纳了吧  嘎嘎

  • 2楼网友:狠傷凤凰
  • 2021-04-27 19:06

呵呵,不告诉你。。。。。

Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long, d As Long, e As Long, t As Long
a = Val(Text1.Text)
b = Val(Text2.Text)
Randomize
c = Int(Rnd * (b - a + 1) + a)
d = Int(Rnd * (b - a + 1) + a)
e = Int(Rnd * (b - a + 1) + a)
Text3.Text = c & "," & d & "," & e
If c < d Then
t = c: c = d: d = t
End If
If c < e Then
t = c: c = e: e = t
End If
If d < e Then
t = d: d = e: e = t
End If
Text4.Text = e & "," & d & "," & c

  • 3楼网友:放肆的依賴
  • 2021-04-27 18:58

Private Sub Command1_Click() Dim a As Long, b As Long, c As Long, d As Long, e As Long, t As Long a = Val(Text1.Text) b = Val(Text2.Text) Randomize c = Int(Rnd * (b - a + 1) + a) d = Int(Rnd * (b - a + 1) + a) e = Int(Rnd * (b - a + 1) + a) Text3.Text = c & "," & d & "," & e If c < d Then t = c: c = d: d = t End If If c < e Then t = c: c = e: e = t End If If d < e Then t = d: d = e: e = t End If Text4.Text = e & "," & d & "," & c

  • 4楼网友:一池湖水
  • 2021-04-27 18:04
int a,b,c; (将输入的数分别赋值给abc然后) if a>b and a>c than print a else if b>c than print b else print c end if end if 手机编辑,条件有限 个别符号没有标出
  • 5楼网友:统治我的世界
  • 2021-04-27 17:40
Private Sub Command1_Click() Dim a As Long, b As Long, c As Long a = InputBox("请输入第1个数的值", "提示") b = InputBox("请输入第2个数的值", "提示") c = InputBox("请输入第3个数的值", "提示") d = IIf(IIf(a > b, a, b) > c, IIf(a > b, a, b), c) x = IIf(IIf(a < b, a, b) < c, IIf(a < b, a, b), c) z = a + b + c - d - x Cls Print a & " , " & b & " , " & c & "按从大到小排列为" & d & " > " & z & " > " & x End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息