maurice1811
New member
- Joined
- May 5, 2015
- Messages
- 2
- Programming Experience
- Beginner
Here is the login process, record adding and updating, I cant see where I'm going wrong,
*******The User will login to their account *****
*****And then add a training record************
********here's the update process ***********
**it seems to not be working correctly as all other lines in the file are deleted apart from the one that need to be updated**
ANY HELP WOULD BE APPRECIATED
*******The User will login to their account *****
sub login() FileOpen(1, CurDir() + "\LoginDetails.csv", OpenMode.Input) logposition1 = 0 Do Until EOF(1) fullline1 = LineInput(1) Dim item() As String = Split(fullline1, ",") 'item () is the array that is splt athlete(logposition1).username = item(0) 'load the first item in the line athlete(logposition1).cpassword = item(1) ' load the 2nd item in the line athlete(logposition1).id = item(6) logposition1 += 1 'counter increase by 1 each time to load a new line each time Loop For count1 As Integer = 0 To logposition1 If username = athlete(count1).username And password = athlete(count1).cpassword Then IDnum = athlete(count1).id addrun() endsub()
*****And then add a training record************
sub addrun() dim x as integer console.writeline("choose workout") console.writeline(1- Run 1 mile") x = console.readline if x = 1 then cal = 10 athlete(IDnum).totalcal += cal update() end sub
********here's the update process ***********
sub update() FileOpen(1, CurDir() + "\LoginDetails.csv", OpenMode.Input) logposition = 0 Do Until EOF(1) fullline1 = LineInput(1) Dim item() As String = Split(fullline1, ",") 'item () is the array that is splt athlete(logposition1).totalcal = item(7) logposition1 += 1 'counter increase by 1 each time to load a new line each time Loop FileOpen(1, CurDir() + "\LoginDetails.csv", OpenMode.Output) ' this allows data to be added to the file For count As Integer = 0 To logposition1 ' count is any number between 0 and i fullline = athlete(count).username & "," & athlete(count).cpassword & "," & athlete(count).id & "," & athlete(count).totalcal PrintLine(1, fullline) Next endsub()
**it seems to not be working correctly as all other lines in the file are deleted apart from the one that need to be updated**
ANY HELP WOULD BE APPRECIATED
Last edited by a moderator: