Help - VB6 - Replacing Line in file  | | |
November 2nd, 2004, 02:09 PM
|
#1 (permalink)
| | Junior Member
Join Date: Jun 2004 Location: USA
Posts: 27
| Help - VB6 - Replacing Line in file
Ok, I'm creating a banking program for school, and I'm wanting to have the people be able to search by social security number.
Saying that people can have more than one account, I can't just search by social security number, because there could be more than one line in the key file like:
|---ssn----|-Acct Num--|
1234567891234567890
Because there could be multiple accounts, is there a way to make it so that when you open a file, and find a specific line, is it possible to take that line, modify it and post it in the place it was found before?
Not sure if this is making much sense. Hope it is
Than you for your time
Darssus
Last edited by darssus : November 2nd, 2004 at 02:19 PM.
|
| |
November 2nd, 2004, 02:18 PM
|
#2 (permalink)
| | Member
Join Date: Jun 2003
Posts: 66
|
I am sure ti is possible, but I am not sure what you are asking. Do you want to open a file, find a specific line/record, update that line and save it back to the file OR do you want to find a specific line/record, open that line and display to the user something different than the data that is in the file?
Maybe I am totally off.
I guess my question is what do you mean by "post it in the place it was found before"? |
| |
November 2nd, 2004, 02:20 PM
|
#3 (permalink)
| | Junior Member
Join Date: Jun 2004 Location: USA
Posts: 27
|
The first one, open file, find line/record, update and save |
| |
November 2nd, 2004, 02:50 PM
|
#4 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
I dont think its possible in VB6
Your best option maybe to
OPen file
** Loop Through File reading Each Line
** Write to a new file each line you read
** Find line you want to update
** Edit the line in a variable
** Write that line to a file
** Continue looping VB is not very efficient for working with text files
Data storage with a text file is typically a bad idea, and even worse idea if you have multiple users.
Database is by far a better option, and editing a single column in a single row is very easy.
Even workign with an Excel spreadsheet would be more efficient if that is an option.
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
|
| |
November 2nd, 2004, 03:31 PM
|
#5 (permalink)
| | Junior Member
Join Date: Jun 2004 Location: USA
Posts: 27
|
Thanks, Excel isn't an option, they want everything custom made (stupid) so I'm having to deal with this. The thing with looping is that there are, if the file is absolutely full, 10000000000 different entries (a 10 digit account number). So that could take a WHILE.
Hmmmmm, that solution may work, only for the beta though, i'll have to figure something out for the full version.
Thanks much |
| |
November 7th, 2004, 10:20 PM
|
#6 (permalink)
| | Ultimate Member
Join Date: Jan 2003 Location: MA / NH
Posts: 1,497
| |
| |
November 7th, 2004, 10:55 PM
|
#7 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
do be warned if they're adamant of using a text file (again I say stupid) they are absolutely limited to ONE concurrent user.
Only one person can have a file open for writing at one time.
MySQL is a good option, but maybe a bit more overhead than you're looking for. |
| |
November 8th, 2004, 12:38 AM
|
#8 (permalink)
| | Ultimate Member
Join Date: Jan 2003 Location: MA / NH
Posts: 1,497
|
Hey darssus what exactly are you working on nowadays anyways?
Blaze |
| |
November 12th, 2004, 12:18 PM
|
#9 (permalink)
| | Junior Member
Join Date: Jun 2004 Location: USA
Posts: 27
|
Blaze: I'm working on a banking program (Senior Project)
With the editing of files, i've decided to have a temp database that all the requests are appended into, then the database file is updated every like 10 seconds from the TEMP file.
I think this will work, what do you people think.
Darssus |
| |
November 12th, 2004, 07:20 PM
|
#10 (permalink)
| | Ultimate Member
Join Date: Jan 2003 Location: MA / NH
Posts: 1,497
|
Sounds like the BPA program me and lee are doing.
Ehh, the only way I've been able to do it is, for example;
Do Until EOF
Input Line 1
Is that the line you need to change?
NO - Write Line 1 to temp file
YES - Write Changed Line to temp file
Loop
Kill input file.
Rename temp file, input file.
Thats what I did for MMP, if ya want the code let me know.
Blaze |
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |