Sap xep cac so

Màu nền
Font chữ
Font size
Chiều cao dòng

Dim i, j As Integer

Dim n As Integer

Dim a(10) As Integer

Private Sub Command1_Click()

Randomize

n = Val(Text1.Text)

For i = 1 To n

    Text2(i).Text = ""

Next

For i = 1 To n

    a(i) = Int((Rnd * 100) + 1)

    Text2(i).Text = a(i)

Next

End Sub

Private Sub Command2_Click()

Dim tam As Integer

For i = 1 To n - 1

    For j = i + 1 To n

        If a(i) > a(j) Then

            tam = a(i)

            a(i) = a(j)

            a(j) = tam

        End If

    Next

Next

For i = 1 To n

    Text2(i).Text = a(i)

Next

End Sub

Private Sub Command3_Click()

Dim tam As Integer

For i = 1 To n - 1

    For j = i + 1 To n

        If a(i) < a(j) Then

            tam = a(i)

            a(i) = a(j)

            a(j) = tam

        End If

    Next

Next

For i = 1 To n

    Text2(i).Text = a(i)

Next

End Sub

Private Sub Command4_Click()

Text1.Text = ""

Dim i As Integer

For i = 1 To 10

    Text2(i).Text = ""

Next

Text1.SetFocus

End Sub

Private Sub Command5_Click()

If MsgBox("Ban co muon thoat khong?", vbQuestion + vbYesNo, "Thong bao") = vbYes Then

    End

Else

    End If

End Sub

Bạn đang đọc truyện trên: Truyen2U.Pro