VB-排序题

为什么我感觉最后输出的第一个数和第二个数谁大谁小不确定呢?哪位大神能告诉我哪儿错了?疑问

 

步骤:

1,打开VB。

2,插入一个TEXT,鼠标拖动成方块。

3,插入一个按钮,并改名为“排序”。

4,双击“排序”按钮,在弹出来的对话框中输入如下内容:

Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim f As Integer
Dim g As Integer
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim m As Integer
Dim n As Integer
Dim o As Integer

Dim swap As Integer
a = Int(Rnd * 1000)
b = Int(Rnd * 1000)
c = Int(Rnd * 1000)
d = Int(Rnd * 1000)
e = Int(Rnd * 1000)
f = Int(Rnd * 1000)
g = Int(Rnd * 1000)
h = Int(Rnd * 1000)
i = Int(Rnd * 1000)
j = Int(Rnd * 1000)
k = Int(Rnd * 1000)
l = Int(Rnd * 1000)
m = Int(Rnd * 1000)
n = Int(Rnd * 1000)
o = Int(Rnd * 1000)

If a < b Then
swap = a
a = b
b = swap
End If
If a < c Then
swap = a
a = c
c = swap
End If
If a < d Then
swap = a
a = d
d = swap
End If
If a < e Then
swap = a
a = e
e = swap
End If
If a < f Then
swap = a
a = f
f = swap
End If
If a < g Then
swap = a
a = g
g = swap
End If
If a < h Then
swap = a
a = h
h = swap
End If
If a < i Then
swap = a
a = i
i = swap
End If
If a < j Then
swap = a
a = j
j = swap
End If
If a < k Then
swap = a
a = k
k = swap
End If
If a < l Then
swap = a
a = l
l = swap
End If
If a < m Then
swap = a
a = m
m = swap
End If
If a < n Then
swap = a
a = n
n = swap
End If
If a < o Then
swap = a
a = o
o = swap
End If
If b < c Then
swap = b
b = c
c = swap
End If
If b < d Then
swap = b
b = d
d = swap
End If
If b < e Then
swap = b
b = e
e = swap
End If
If b < f Then
swap = b
b = f
f = swap
End If
If b < g Then
swap = b
b = g
g = swap
End If
If b < h Then
swap = b
b = h
h = swap
End If
If b < i Then
swap = b
b = i
i = swap
End If
If b < j Then
swap = b
b = j
j = swap
End If
If b < k Then
swap = b
b = k
k = swap
End If
If b < l Then
swap = b
b = l
l = swap
End If
If b < m Then
swap = b
b = m
m = swap
End If
If b < n Then
swap = b
b = n
n = swap
End If
If b < o Then
swap = b
b = o
o = swap
End If
If c < d Then
swap = c
c = d
d = swap
End If
If c < e Then
swap = c
c = e
e = swap
End If
If c < f Then
swap = c
c = f
f = swap
End If
If c < g Then
swap = c
c = g
g = swap
End If
If c < h Then
swap = c
c = h
h = swap
End If
If c < i Then
swap = c
c = i
i = swap
End If
If c < j Then
swap = c
c = j
j = swap
End If
If c < k Then
swap = c
c = k
k = swap
End If
If c < l Then
swap = c
c = l
l = swap
End If
If c < m Then
swap = c
c = m
m = swap
End If
If c < n Then
swap = c
c = n
n = swap
End If
If c < o Then
swap = c
c = o
o = swap
End If

If d < e Then
swap = d
d = e
e = swap
End If
If d < f Then
swap = d
d = f
f = swap
End If
If d < g Then
swap = d
d = g
g = swap
End If
If d < h Then
swap = d
d = h
h = swap
End If
If d < i Then
swap = d
d = i
i = swap
End If
If d < j Then
swap = d
d = j
j = swap
End If
If d < k Then
swap = d
d = k
k = swap
End If
If d < l Then
swap = d
d = l
l = swap
End If
If d < m Then
swap = d
d = m
m = swap
End If
If d < n Then
swap = d
d = n
n = swap
End If
If d < o Then
swap = d
d = o
o = swap
End If

If e < f Then
swap = e
e = f
f = swap
End If
If e < g Then
swap = e
e = g
g = swap
End If
If e < h Then
swap = e
e = h
h = swap
End If
If e < i Then
swap = e
e = i
i = swap
End If
If e < j Then
swap = e
e = j
j = swap
End If
If e < k Then
swap = e
e = k
k = swap
End If
If e < l Then
swap = e
e = l
l = swap
End If
If e < m Then
swap = e
e = m
m = swap
End If
If e < n Then
swap = e
e = n
n = swap
End If
If e < o Then
swap = e
e = o
o = swap
End If
If f < g Then
swap = f
f = g
g = swap
End If
If f < h Then
swap = f
f = h
h = swap
End If
If f < i Then
swap = f
f = i
i = swap
End If
If f < j Then
swap = f
f = j
j = swap
End If
If f < k Then
swap = f
f = k
k = swap
End If
If f < l Then
swap = f
f = l
l = swap
End If
If f < m Then
swap = f
f = m
m = swap
End If
If f < n Then
swap = f
f = n
n = swap
End If
If f < o Then
swap = f
f = o
o = swap
End If
If g < h Then
swap = g
g = h
h = swap
End If
If g < i Then
swap = g
g = i
i = swap
End If
If g < j Then
swap = g
g = j
j = swap
End If
If g < k Then
swap = g
g = k
k = swap
End If
If g < l Then
swap = g
g = l
l = swap
End If
If g < m Then
swap = g
g = m
m = swap
End If
If g < n Then
swap = g
g = n
n = swap
End If
If g < o Then
swap = g
g = o
o = swap
End If
If h < i Then
swap = h
h = i
i = swap
End If
If h < j Then
swap = h
h = j
j = swap
End If
If h < k Then
swap = h
h = k
k = swap
End If
If h < l Then
swap = h
h = l
l = swap
End If
If h < m Then
swap = h
h = m
m = swap
End If
If h < n Then
swap = h
h = n
n = swap
End If
If h < o Then
swap = h
h = o
o = swap
End If
If i < j Then
swap = i
i = j
j = swap
End If
If i < k Then
swap = i
i = k
k = swap
End If
If i < l Then
swap = i
i = l
l = swap
End If
If i < m Then
swap = i
i = m
m = swap
End If
If i < n Then
swap = i
i = n
n = swap
End If
If i < o Then
swap = i
i = o
o = swap
End If
If j < k Then
swap = j
j = k
k = swap
End If
If j < l Then
swap = j
j = l
l = swap
End If
If j < m Then
swap = j
j = m
m = swap
End If
If j < n Then
swap = j
j = n
n = swap
End If
If j < o Then
swap = j
j = o
o = swap
End If
If k < l Then
swap = k
k = l
l = swap
End If
If k < m Then
swap = k
k = m
m = swap
End If
If k < n Then
swap = k
k = n
n = swap
End If
If k < o Then
swap = k
k = o
o = swap
End If
If l < m Then
swap = l
l = m
m = swap
End If
If l < n Then
swap = l
l = n
n = swap
End If
If l < o Then
swap = l
l = o
o = swap
End If
If m < n Then
swap = m
m = n
n = swap
End If
If m < o Then
swap = m
m = o
o = swap
End If
If n < o Then
swap = n
n = o
o = swap
End If
Print a & "," & b, c & "," & d, e & "," & f, g & "," & h, i & "," & j, k & "," & l, m & "," & n, o & ""
End Sub

 5,单击运行,鼠标点击排序开始运行。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值