Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
Dim?tStrings(100)?As?String
Dim?i,?j?As?Integer
For?i?=?0?To?ListBox1.Items.Count?-?1
tStrings(i)?=?ListBox1.Items(i)
Next
'冒泡排序
For?i?=?0?To?ListBox1.Items.Count?-?1
For?j?=?0?To?ListBox1.Items.Count?-?i?-?2
If?tStrings(j)?>?tStrings(j?+?1)?Then
Dim?tmp?As?String
tmp?=?tStrings(j)
tStrings(j)?=?tStrings(j?+?1)
tStrings(j?+?1)?=?tmp
End?If
Next
Next
For?i?=?0?To?ListBox1.Items.Count?-?1
ListBox2.Items.Add(tStrings(i))
Next
End?Sub
Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load
ListBox1.Items.Add("China")
ListBox1.Items.Add("America")
ListBox1.Items.Add("Japan")
ListBox1.Items.Add("Soccer")
ListBox1.Items.Add("Tennis")
ListBox1.Items.Add("Basketball")
End?Sub
End?Class
運行結果: