VB.NET编程实现
Public Class Form1
'声明一个包含6个元素的字符串数组Student
Dim Student(5) As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'对数组元素赋值
Dim i As Integer
Student(0) = "张三"
Student(1) = "王刚"
Student(2) = "李想"
Student(3) = "李华"
Student(4) = "陈晨" : Student(5) = "钱进"
'在文本框中进行分行显示,每个元素占一行。vbCrLf:回车换行
For i = 0 To 5
TextBox1.Text &= Student(i) & vbCrLf
Next
End Sub
Private Sub btnSort_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSort.Click
'对数组进行排序
Dim a As String
Array.Sort(Student)
'在文本框中显示排序后的元素
For Each a In Student
TextBox2.Text &= a & vbCrLf
Next
End Sub
End Class
排序vb.net教程前
排序后