|
-
Apr 8th, 2008, 08:15 AM
#1
Thread Starter
New Member
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:
Private Sub cmdSelect_Click()
'DISPLAY CONTENTS OF FILE
RecordLen = Len(TResults)
ChanNum = FreeFile
userin = InputBox$("Please enter a filename")
Filename = userin & ".txt"
Open Filename For Random As #1
Record = InputBox("Please enter the number of record which you wish to view", "View Record")
Get #ChanNum, Record, TResults
PicRn.Print TResults.name
PicRt.Print TResults.time
Close #1
End Sub
Private Sub CmdWrite_Click()
RecordLen = Len(TResults)
'ChanNum = FreeFile
userin = InputBox$("Please enter a filename ")
Filename = userin & ".txt"
Numero = InputBox("How many competitors in race?", "No People")
Open Filename For Random As #1
For Reccy = 1 To Numero
Comp1.name = InputBox("Please enter Name for Lane " & Reccy)
Comp1.time = InputBox("Please enter Time for Lane " & Reccy)
picc1.Print (Comp1.name)
pict1.Print (Comp1.time)
Put #1, Reccy, Comp1
Next Reccy
Close #1
End Sub
Private Sub CmdDisplayFile_Click()
'DISPLAY CONTENTS OF FILE
Dim repeats As Integer
RecordLen = Len(TResults)
ChanNum = FreeFile
userin = InputBox$("Please enter a filename ")
Filename = userin & ".txt"
Open Filename For Random As #1
For repeats = 1 To 6
Get #ChanNum, repeats, Comp1
picc1.Print Comp1.name
pict1.Print Comp1.time
Next repeats
Close #1
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|