最好是用选择结构 急急急!!!
急急急!!!VB:用键盘输入3个数,求3个数按从小到大排列输出
- 提问者网友:斯文败类
- 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
- 5楼网友:统治我的世界
- 2021-04-27 17:40