Teen Programmers Unite  
 

 

Return to forum top

File Reading VB6

Posted by andymcnab [send private reply] at September 20, 2002, 12:33:38 PM

Hello,
I want to make a database thing and i want the user to be able to enter peices of text and numbers into text boxes and then they can save them all to one text file or DAT file. So they can then be read after back into the same text boxes. I understand that within the codee you need to tell it to seperate each peice of data with a certain character eg. a comma. Then you can read them back into the program. I am just a bit stuck with this file handling stuff, i can do basic stuff like saving stuff to files and opening stuff from files. I am just puzzled with this!!!!!
Appreciate any help Thanks Tom
ICQ: 170063348 (feel free to add me to your list!)
E Mail: tom@elitehaven.net
Thnx again!

Posted by eXorcus [send private reply] at September 21, 2002, 02:19:36 PM

If you want to input data in comma separated format, you simply need to read it into a variable using something like:
Do While NOT(EOF(1))
Input #1, MyVar
Loop

To write a comma separated file, you can use the Write function, which will surround each variable written to the file in quotations ("MyVarValue1", "MyVarValue2").
Write #1, MyVar 'I beleive this is correct, but I don't use Write much. =P

If you don't like that formatting, you can use the Print statement for more control. IE:
Print #1, MyVar & ","
This will append a "," to every value written to the file, so you can input them after using the Input function.

Hope this helps!

Posted by manoj [send private reply] at September 21, 2002, 11:01:04 PM

If the requirement is just of an interface and the user is not concerned with the dat file....why not use an actual database mgmt softwr? It won't require any formatting and stuff and will allow for protection, easy handling etc.

Posted by eXorcus [send private reply] at September 22, 2002, 10:47:33 AM

That is a good idea. I beleive the VB text boxes and such can be bound to certain fields in a database created with the VB Visual Data Manager (Which makes DBA files I beleive) and will write changes to the DBA by calling one method on the Data control. We did that in grade 11 programming I think...man that was a long time ago.

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.