// Sorting numbers
Public Class Form1
Dim n, no, t As Integer
Dim a(10) As Integer
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles GroupBox1.Enter
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Static i As Integer
n = Val(TextBox1.Text)
TextBox2.Focus()
If (i < n) Then
a(i) = Val(TextBox2.Text)
ListBox1.Items.Add(a(i))
i = i + 1
End If
If (i >= n) Then
MsgBox("array full")
End If
TextBox2.Clear()
TextBox2.Focus()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Focus()
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
n = Val(TextBox1.Text)
For i = 0 To n - 2
For j = i + 1 To n - 1
If (a(j) > a(i)) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next
Next
For i = 0 To n - 1
ListBox2.Items.Add(a(i))
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
TextBox1.Clear()
TextBox2.Clear()
ListBox1.Items.Clear()
ListBox2.Items.Clear()
End Sub
End Class