467,881 Members | 1,220 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,881 developers. It's quick & easy.

Help: Reading a Txt File, Duplicates, Appending

I used to study VB in college but it's been a while. Ironically I've forgotten most of it just as I've found the perfect opportunity to utilize it.

I want the application to read lines of text in a textbox (names of students), scan a txt file to see if the names are on the list already, then display in a second textbox all the names which are new. Then write the new names to the txt file so that they won't be counted twice next time.

Some background: I work in a tutoring center in a school, and my colleague is going crazy trying to figure out a system of trying to keep track of how many new students we have a day. Every week we have to submit numbers of how many new students we worked with, in different areas. Problem is, once one of us has worked with a student, that student isn't allowed to be counted in the same subject by the rest of us. (There are 1500 students in the school.) So I figured simply entering in all the names we all say we've worked with that week, and letting the computer figure out which ones are already on the list, would be a great solution. I really wanted to help my colleague cut down on her bureaucratic work.

I've figured out how to append text to a file, but not search for the names, check for duplicates or display the new names...

Hope that makes sense.

Thanks!
Nov 7 '06 #1
  • viewed: 2198
Share:
1 Reply
Expert 8TB
I used to study VB in college but it's been a while. Ironically I've forgotten most of it just as I've found the perfect opportunity to utilize it.

I want the application to read lines of text in a textbox (names of students), scan a txt file to see if the names are on the list already, then display in a second textbox all the names which are new. Then write the new names to the txt file so that they won't be counted twice next time.

Some background: I work in a tutoring center in a school, and my colleague is going crazy trying to figure out a system of trying to keep track of how many new students we have a day. Every week we have to submit numbers of how many new students we worked with, in different areas. Problem is, once one of us has worked with a student, that student isn't allowed to be counted in the same subject by the rest of us. (There are 1500 students in the school.) So I figured simply entering in all the names we all say we've worked with that week, and letting the computer figure out which ones are already on the list, would be a great solution. I really wanted to help my colleague cut down on her bureaucratic work.

I've figured out how to append text to a file, but not search for the names, check for duplicates or display the new names...

Hope that makes sense.

Thanks!
One way would be to load all the names from the text box into an array. Then as you read through the text file (Open "Text.txt" for Input Access Read Shared As #1 ... Do Until Eof(1) ... Line Input ExistingName) check each against the array (For I = 1 to ArraySize ... If NewName(I) = ExistingName Then blah blah... Next)

Once you've eliminated the dupes, report those which are left somehow, then
Expand|Select|Wrap|Line Numbers
  1. Close #1 ' (If you haven't already)
  2. Open "Text.txt" For Append Access Read Write Lock Write As #1
  3. For I = 1 to ArraySize
  4.   If this-one-is-new    ' however you flagged that - possibly a Boolean array
  5.     Print #1, NewName(I)
  6.   End If
  7. Next
  8. Close #1    
  9.  
Nov 7 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

21 posts views Thread by Dan | last post: by
5 posts views Thread by andrewcw | last post: by
2 posts views Thread by sbowman | last post: by
reply views Thread by jon | last post: by
118 posts views Thread by Chuck Cheeze | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.