I have a .dat file with data like this in
"James","Project5","15/05/2010","3"
"Matt","Project1","01/05/2010","5"
"Ellie","Project5","24/04/2010","1"
"Ellie","Project2","10/05/2010","3"
"Matt","Project3","03/05/2010","4"
It gets written in with thise code.
Private Sub Command2_Click()
Open jobs For Append As #1
Write #1, Combo1, Combo3, Combo2, Text3
Close #1
End Sub
I instead would like to write it to the file so that if a persons name is already in the file then it would just put the data in the file, under their that is already there but without the name. I can't figure out how to do this but this is what I would like it to end up like.
"James","Project5","15/05/2010","3"
"Matt","Project1","01/05/2010","5"
"Ellie","Project5","24/04/2010","1"
"Project2","10/05/2010","3"
"M开发者_JAVA技巧att","Project3","03/05/2010","4"
Any help would be fantastic!
First read in the whole file into memory and store it as an array (read it in as one long string and the
Split
it onvbNewLine
).Then loop through the array and do your changes.
Write the data to a temporary filename.
Replace the original file with the temporary file. FSO (File System Objects) have some easy to use functions to delete and move files.
You could use an ini file for your schema. For example:
[James]
project1=01/05/2010,5
project2=24/04/2010,1
精彩评论