VB用inputbox连续输入10个数 然后分别进行升降序排列 然后结果显示在TEXT上
2个回答
展开全部
Private Sub Command1_Click()
Dim a(1 To 10) As Integer
Dim n As Integer
Dim i As Integer
Dim j As Integer
For i = 1 To 10
a(i) = Val(InputBox("输入第" & i & "个数"))
Next i
For i = 1 To 10
For j = 1 To 10
If a(i) < a(j) Then
n = a(i)
a(i) = a(j)
a(j) = n
End If
Next j
Next i
Print "升序"
Text1.Text = "升序:"
For i = 1 To 10
Print a(i);
Text1.Text = Text1.Text & a(i) & " "
Next
Print
Print "降序"
Text1.Text = Text1.Text & "降序:"
For i = 10 To 1 Step -1
Print a(i);
Text1.Text = Text1.Text & a(i) & " "
Next i
Print
End Sub
'添加一个按钮然后单击
Dim a(1 To 10) As Integer
Dim n As Integer
Dim i As Integer
Dim j As Integer
For i = 1 To 10
a(i) = Val(InputBox("输入第" & i & "个数"))
Next i
For i = 1 To 10
For j = 1 To 10
If a(i) < a(j) Then
n = a(i)
a(i) = a(j)
a(j) = n
End If
Next j
Next i
Print "升序"
Text1.Text = "升序:"
For i = 1 To 10
Print a(i);
Text1.Text = Text1.Text & a(i) & " "
Next
Print "降序"
Text1.Text = Text1.Text & "降序:"
For i = 10 To 1 Step -1
Print a(i);
Text1.Text = Text1.Text & a(i) & " "
Next i
End Sub
'添加一个按钮然后单击
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
option base 1
Private Sub Command1_Click()
dim b(10) as long , a as long , t as long , n as long
for a = 1 to 10
b(a)=inputbox ("shu ru di " & a )
next
for a = 1 to 9
for n = a+1 to 10
if b(a) > b(n ) then
t=b(a): b(a)=b(n):b(n)=t
next b
next a
for a = 1 to 10
text1.text = text1.text & b(a)
next
end sub
Private Sub Command1_Click()
dim b(10) as long , a as long , t as long , n as long
for a = 1 to 10
b(a)=inputbox ("shu ru di " & a )
next
for a = 1 to 9
for n = a+1 to 10
if b(a) > b(n ) then
t=b(a): b(a)=b(n):b(n)=t
next b
next a
for a = 1 to 10
text1.text = text1.text & b(a)
next
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询