I currently user logon information stored in one file, i wish to be able to delete users from this file currently i am selecting the users from a lstbox which retrieves all the user names from the txtfile.
Public Sub CmdRetrieveUsers_Click()
LstUsr.Clear
CmdEditUsr.Enabled = True
Open App.Path & "\Logon.Password Info.txt" For Input As #1
Do While Not EOF(1)
Input #1, Username, PasswordFromFile, AccountType
LstUsr.AddItem (Username)
Loop
Close #1
End Sub
What i want to be able to do is, select the user you wish to delete by selecting/clicking on their username from the list box. So far i have read that i need to open the file for input (reading), open a temp file for output/append?? then transfer the data across and kill the original file then rename the temp file. The code i have managed to write so far.
Private Sub CmdDelete_Click()
Open App.Path & "\Logon.Password Info.txt" For Input As #1
Open App.Path & "\Logon.Password Temp.txt" For Output As #2
For i = 0 To LstUsr.ListIndex - 1
Input #1, Username, Password, AccountType
Write #2, Username, Password, AccountType
Next i
For i = LstUsr.ListIndex To LstUsr.ListCount -1
Input #1, Username, Password, AccountType
Write #2, Username, Password, AccountType
Next i
Close #2
Close #1
'Kill App.Path & "\Logon.Password Info.txt"
'Name App.Path & "\Logon.Password Temp.txt" As App.Path & "\Logon.Password Info.txt"
End Sub
I know i've gone wrong somewhere in it but just cant figure out where.
Thanks in advance :)