By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

Help: Reading a Txt File, Duplicates, Appending

P: 1
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
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
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.