Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
How can i use text file (from notepad) as database ?
View previous topic :: View next topic  
Author Message
Tsunami
Newbie


Joined: 05 Dec 2003
Posts: 2

PostPosted: Dec 5th, 2003 09:47 AM    Post subject: How can i use text file (from notepad) as database ? Reply with quote

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
View user's profile Send private message Send e-mail
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Dec 6th, 2003 08:41 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic