定义一个数组,想通过textbox给它赋值,然后在label1控件上显示出来,最后在排序。

定义一个数组,想通过textbox给它赋值,然后在label1控件上显示出来,最后在排序。就是输入一个数字,然后单击一下button1控件,它就在label上显示出来,再... 定义一个数组,想通过textbox给它赋值,然后在label1控件上显示出来,最后在排序。就是输入一个数字,然后单击一下button1控件,它就在label上显示出来,再单击下,又显示个数字,让它一个一个的显示。最后再单击button2,给他们排序,都显示在label2上。请问怎么做啊?谢谢啦 展开
 我来答
匿名用户
2013-11-05
展开全部
Public Class Form1
Private num(100) As Integer
Private len As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = ""
Label2.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = Val(TextBox1.Text)
num(len) = i
len += 1
Label1.Text = i.ToString
TextBox1.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim int As Integer = 0
For i As Integer = 0 To len - 2
For j As Integer = i To len - 1
If num(i) > num(j) Then
int = num(i)
num(i) = num(j)
num(j) = int
End If
Next
Next
For i As Integer = 0 To len - 1
Label2.Text += num(i).ToString & " "
Next
End Sub
End Class
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式