Form1 Program to Sort a Text File Form1% DiskDrv PatternBox QuitBtn &Quit TreeDir FileFlb SortfileBtn &Sort text file ViewFileBtn &View File PrintFileCom &Print File TextBox DriveLbl Drive: PatternLbl Filename: DirectoryLbl Directory: FilesLbl Files: Form_ClickZ @ Form_LoadY DateFormatOpt Value> TimeFormat TimeFormatOpt* NowBtn_Click TextBox QuitBtn_ClickV CountryCmb_Change% CountryCmbI ComboItemm VScroll1_Change TimeScl_Changed ScrollBarValueBox TimeSclc ScrollValueBox Label1_Click TimerBtn_Clicke Count Total TextLine@ TimerBtn Caption] Diff@ ScrollValueBox_Change MaxLbl_Click~ TextBox_Change@ TextBox_LostFocus QuitBtn Enabled False MIN_VALUE MAX_VALUE MinLble MaxLbl SmallChange LargeChange properties PrintBtn_Click FilenameI CurrentLineNumber$ MAX_LINES/ PrintHeadingq Printer; BadFileG ExitSub PrintHadingW PageNumber PageNum} PageNumStr PrintTab TAB_SIZE5 PageNumberStr Pageq TextBox_KeyPress KeyAScii Check4_Clicky HiddenChk_Click" PatternBox_Change5 WindowStaten PatternBoxw DiskDrv_Change TreeDir DiskDrv1 Drive FileFlb_Click FileFlb ArchiveChk_Click Archive ArchiveChk SystemChk_Click System^ SystemChk ReadOnlyChk_Click ReadOnly ReadOnlyChk NormalChk_Click Normal( NormalChkh Hidden HiddenChkK TreeDir_Change PatternBox_KeyDown KeyCodeD Shift PatternBox_KeyPressJ PatternBox_LostFocus Pattern FindFileBtn_Click5 Text1_Change~ FindFileBox ListCountx NotFound FindFileBox_Change FindFileBox_KeyPress ListIndexd Label2_ClickX BinSearchE Medianm Media9 FileListBox FileFlb_PatternChange DirectoryLbl_Click DriveLbl_Click FileAttrFrm_DragDrop Source FilesLbl_Click FindFileLbl_Click PatternLbl_Clicki SUB_KEYWORD FUNCTION_KEYWORD END_SUBB END_FUNCTION SortVBfileBtn_Click GetFilenamef GetFileExt Filename_# MainFilename0 ExtFilenameK InputFileNumQ FreeF" ProcName Procy GetExtFile IsSub/ LineNum CountProc Rename FileNum FullFilename TheFilename MaxProc# CountPorc GetProcName GetSubName GetFunctionName OutputFileNum GetTempFilename GetTempFile SortProcedureData OutputFileI CountPoc8 Skipp SkipY InOrderd IntegerDim inetger TempProcName TempFileNum MousePointer Form1 ViewFileBtn_Click: PrintFileCom_Click^ Switch fileBtn_Click SortFileBtn_Click LineIndex NumLines BinFileNum start ViewFileBtn_KeyUpp LineI LineJ LenBigTextLine LenBigLextLine LineLen LinePos temporary buffer DiskDrv_Change update file tree path when the disk is changedg Form_Load *.txt *.txt GetFileExt GetFilename PatternBox_KeyPress PatternBox_LostFocus find first spacef PrintFileCom_Click hourglass QuitBtn_Click SortFileBtn_Click index of linesi byte index for line size of linef number of text lines in filet indices indices used in sorting in-order flag lines of text full filename main filename extension name declare variables for file I/O channels hourglass delete previous ".BAK" file turn off error-handler rename file as .BAK first pass simply counts the number of linesb file is empty rename file back to originalA The text file is empty! Information redimension the arrays- LineIndex(0) is used in swapping the other elements of LineIndexx start pass 2 position of first byte- read text linet set index of line store length of line calculate the byte position of the next line the 2 represent the Chr$(13)+Chr$(10) charactersc that delimit the text lines close file buffersi sort the text lines start the Comb-sort algorithm get indirect indices get line IC get line JC swap LineIndex elements the element LineIndex(0) is used as a temporary swap buffer now copy lines from .BAK file into the text filei open as binary get the I'th line size string LineI to read the I'th text linet use Get and Put to copy lines close all buffers TextBox_KeyPress TreeDir_Change ViewFileBtn_Click