home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Help - VB6 - Replacing Line in file

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2130
Discussions: 200,919, Posts: 2,379,064, Members: 246,287
Old November 2nd, 2004, 02:09 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Jun 2004
Location: USA
Posts: 27
Send a message via AIM to darssus
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.
darssus is offline   Reply With Quote
Old 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"?
tcompguy is offline   Reply With Quote
Old November 2nd, 2004, 02:20 PM     #3 (permalink)
Junior Member
 
Join Date: Jun 2004
Location: USA
Posts: 27
Send a message via AIM to darssus
The first one, open file, find line/record, update and save
darssus is offline   Reply With Quote
Old 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.
vass0922 is online now   Reply With Quote
Old November 2nd, 2004, 03:31 PM     #5 (permalink)
Junior Member
 
Join Date: Jun 2004
Location: USA
Posts: 27
Send a message via AIM to darssus
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
darssus is offline   Reply With Quote
Old November 7th, 2004, 10:20 PM     #6 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
You COULD just use a MySQL database

www.mysql.com
www.sqlcourse.com


Blaze
Blazer06 is offline   Reply With Quote
Old 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.
vass0922 is online now   Reply With Quote
Old November 8th, 2004, 12:38 AM     #8 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
Hey darssus what exactly are you working on nowadays anyways?


Blaze
Blazer06 is offline   Reply With Quote
Old November 12th, 2004, 12:18 PM     #9 (permalink)
Junior Member
 
Join Date: Jun 2004
Location: USA
Posts: 27
Send a message via AIM to darssus
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
darssus is offline   Reply With Quote
Old November 12th, 2004, 07:20 PM     #10 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
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
Blazer06 is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic questions PassnThru Applications and Operating Systems 9 March 10th, 2004 01:59 AM
I'm a n00b, and I need help(Visual basic) Andybebad Webmastering and Programming 9 November 14th, 2003 08:11 PM
AutoCAD 2002 and Visual Basic 6, the nightmare begins! wraithofdark Webmastering and Programming 2 October 28th, 2002 06:52 PM
VS.NET Rant vass0922 Webmastering and Programming 3 September 6th, 2002 02:17 PM
Can't run my VB program on win2000... Mr. NoOne Webmastering and Programming 7 December 10th, 2001 01:46 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2849)
Obama the Muslim (12)
Why is Khalid Sheikh Mohammed even .. (9)
Is the PSU I received dead? (10)
windows vista security holes (7)
Foreign voltage (10)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (9)
Print spooler problem (12)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
New Computer wont recognize XP disc (7)
Ideal cheap graph card for PC-Gamin.. (15)
EVGA 9800 gtx help with finding a g.. (8)
Recent Discussions
monitor will not turn on at all, (1)
Print spooler problem (12)
Display shows 3x5 inch in middle of s.. (2)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (33)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Help getting around port 80 for camer.. (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
windows vista security holes (7)
Install XP pro and a Vista laptop ?? (9)
EVGA 9800 gtx help with finding a goo.. (8)
Modern Warfare For the PC (32)
Problem with speed step/turbo boost? (1)
Modern Warfare 2: Who Bought It? (61)
SIS 740 and Widescreen (8)
Baffling Problem with my CPU/MoBo's. .. (0)
HIS HD5770 graphic card question (15)
Best file format to play on Windows H.. (0)
PSP Go bought in Japan (0)
Asus P4G8X Mobo (3)
Need hard disk drivers (4)
windows 7 internet problem (4)


All times are GMT -4. The time now is 07:30 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28