'************************************************************************************* '* Name: CS 100-01 * '* Program: Bubble Sort * '* Date: 4/8/03 * '* Description: This program is designed to demonstrate Bubble Sort * '************************************************************************************* Option Explicit 'Global variables Dim intInFileNum As Integer Private Sub Form_Load() Const strREP_FILE = "\SalesReps.csv" Dim strFilePath As String 'Open the Files strFilePath = App.Path & strREP_FILE intInFileNum = FreeFile Open strFilePath For Input As #intInFileNum End Sub Private Sub btnStart_Click() Const intMAX_REPS = 15 Dim intCount1 As Integer Dim intCount2 As Integer Dim intNumReps As Integer Dim strSalesRep(1 To intMAX_REPS) As String Dim strTempRep As String 'Read the Data Files Do Until EOF(intInFileNum) intNumReps = intNumReps + 1 Input #intInFileNum, strSalesRep(intNumReps) Loop 'Sort the Reps For intCount1 = 1 To intNumReps - 1 For intCount2 = intCount1 To intNumReps If strSalesRep(intCount1) > strSalesRep(intCount2) Then strTempRep = strSalesRep(intCount2) strSalesRep(intCount2) = strSalesRep(intCount1) strSalesRep(intCount1) = strTempRep End If Next intCount2 Next intCount1 'Print the Reps For intCount1 = 1 To intNumReps picSort.Print strSalesRep(intCount1) Next intCount1 End Sub Private Sub btnEnd_Click() Close End End Sub