Results 1 to 5 of 5

Thread: School Project - manipulating .txt files

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    4

    School Project - manipulating .txt files

    Any chance of some help with a school project?

    For a project I’ve been set the task of creating an athletics results and reporting system (combining another of my interests) in VB using random access .txt files.

    So far I’ve been able to write data to a file, read the data from a file, and select and read an individual record from a file using its record number. Really basic stuff I know.

    What I want to be able to do is store all the names of the competitors, event, heat, place and time in a single txt file, then from this extract the relevant data and sort all of the competitors in order by time.

    Here is what I already have:
    vb Code:
    1. Private Sub cmdSelect_Click()
    2.  
    3. 'DISPLAY CONTENTS OF FILE
    4.  
    5.  RecordLen = Len(TResults)
    6.  ChanNum = FreeFile
    7.  
    8. userin = InputBox$("Please enter a filename")
    9.  
    10. Filename = userin & ".txt"
    11.  
    12. Open Filename For Random As #1
    13.  
    14. Record = InputBox("Please enter the number of record which you wish to view", "View Record")
    15.  
    16. Get #ChanNum, Record, TResults
    17.  
    18. PicRn.Print TResults.name
    19.  PicRt.Print TResults.time
    20.  
    21.  Close #1
    22.  
    23.  End Sub
    24.  
    25. Private Sub CmdWrite_Click()
    26.  
    27.  RecordLen = Len(TResults)
    28.  'ChanNum = FreeFile
    29.  
    30. userin = InputBox$("Please enter a filename ")
    31.  
    32. Filename = userin & ".txt"
    33. Numero = InputBox("How many competitors in race?", "No People")
    34.  
    35. Open Filename For Random As #1
    36.  
    37. For Reccy = 1 To Numero
    38.  
    39.  Comp1.name = InputBox("Please enter Name for Lane " & Reccy)
    40.  Comp1.time = InputBox("Please enter Time for Lane " & Reccy)
    41.     picc1.Print (Comp1.name)
    42.     pict1.Print (Comp1.time)
    43. Put #1, Reccy, Comp1
    44.  
    45. Next Reccy
    46.  
    47.  Close #1
    48. End Sub
    49.  
    50. Private Sub CmdDisplayFile_Click()
    51.  
    52. 'DISPLAY CONTENTS OF FILE
    53.  
    54. Dim repeats As Integer
    55.  
    56.  RecordLen = Len(TResults)
    57.  ChanNum = FreeFile
    58.  
    59. userin = InputBox$("Please enter a filename ")
    60.  
    61. Filename = userin & ".txt"
    62.  
    63. Open Filename For Random As #1
    64.  
    65. For repeats = 1 To 6
    66.  
    67. Get #ChanNum, repeats, Comp1
    68.  
    69. picc1.Print Comp1.name
    70.  pict1.Print Comp1.time
    71.  
    72. Next repeats
    73.  
    74.  Close #1
    75.  
    76.  End Sub

    Any ideas?

    I know this seems awkward, using text files for a database, but the project has to use some of the stuff from the course and has to be of a specific level so I can’t use VB as a front end for a MS Excel database (I don’t think).

    Any help would be much appreciated
    Last edited by Hack; Apr 8th, 2008 at 08:20 AM. Reason: Added Code Highlight Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width