 |
| View previous topic :: View next topic |
| Author |
Message |
Tsunami Newbie
Joined: 05 Dec 2003 Posts: 2
|
Posted: Dec 5th, 2003 09:47 AM Post subject: How can i use text file (from notepad) as database ? |
|
|
I have an assignment but i am not allowed to use database and my tutor told me to use text file from notepad, write the data and use the code to read each line of the file. Is there anybody know this tricky way to get around with database ? Can you post the code, thank you ! _________________ No softwares and programs are perfect |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Dec 6th, 2003 08:41 AM Post subject: |
|
|
Hi!
You can use the following format in a text file and use it as a database.
First i'll explain the format which can be used with VB in text files.
Format:
Suppose you have 3 fields named Name, Age and Sex. So the data should look like below in a text file based database.
| Code: | "Avis", "20", "Male"
"Bhushan", "25", "Male"
"Haymanti", "19", "Female"
"Akanksha", "15", "Female" |
So your file should look something like above. And following is the code at retrieve the above stuff from the text file which gets loaded into 3 list boxes named List1, List2 and List3.
Retrieve Code:
| Code: | Dim Name, Age, Sex As String
Open "c:\myfile.txt" For Input As #1
Do Until EOF(1)
Input #1, Name, Age, Sex
List1.AddItem Name
List2.AddItem Age
List3.AddItem Sex
Loop
Close #1 |
I hope this helps! If you need any further help then please let us know!
Thanks! _________________ Code Snippets, Tutorials, Utilities, Controls
Low cost Web Hosting
Hosting starts at as low as $4 per year!
Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags! |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|