home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frm7_4_2
- Caption = "Stone Age Friends"
- ClientHeight = 972
- ClientLeft = 1068
- ClientTop = 1920
- ClientWidth = 6300
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 7.8
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 972
- ScaleWidth = 6300
- Begin VB.PictureBox picNames
- Height = 255
- Left = 120
- ScaleHeight = 204
- ScaleWidth = 5964
- TabIndex = 1
- Top = 600
- Width = 6012
- End
- Begin VB.CommandButton cmdSort
- Caption = "Perform a Bubble Sort"
- Height = 375
- Left = 1440
- TabIndex = 0
- Top = 120
- Width = 3015
- End
- Attribute VB_Name = "frm7_4_2"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim nom(1 To 5) As String
- Private Sub cmdSort_Click()
- Dim passNum As Integer, i As Integer, temp As String
- 'Bubble sort names
- For passNum = 1 To 4 'Number of passes is 1 less than number of items
- For i = 1 To 5 - passNum 'Each pass needs 1 less comparison
- If nom(i) > nom(i + 1) Then
- temp = nom(i)
- nom(i) = nom(i + 1)
- nom(i + 1) = temp
- End If
- Next i
- Next passNum
- 'Display alphabetized list
- picNames.Cls
- For i = 1 To 5
- picNames.Print nom(i),
- Next i
- End Sub
- Private Sub Form_Load()
- 'Fill array with names
- nom(1) = "Pebbles"
- nom(2) = "Barney"
- nom(3) = "Wilma"
- nom(4) = "Fred"
- nom(5) = "Dino"
- End Sub
-