Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Txt doc and Dat files using VB

Original Message
Name: basicdos
Date: January 3, 2008 at 17:35:20 Pacific
Subject: Txt doc and Dat files using VB
OS: WinMe/XP
CPU/Ram: int III / 255Mb
Model/Manufacturer: E -machine
Comment:
Hello all
Happy New Year

Ive created a telephone number and info program
it works fine but here is the question. I wrote this program and used a simple text file as the storage space for all my information. I cycle through it using readline statements
I had no problem with this method writing, appending and deleting all works fine.
the problem I encountered is that the file had an over run of some type. I surmised the problem to be a limit to the length of simple text files.
I did some experimentatiion and found I can very easily save the info as a simple doc file there doesnt seem to be a problem with length here...Am I Right?

Ok but I realize this system im using is amateurish, but it does work. I Should probably be using arrays in Ram and saveing to disk as a .dat file but im not really sure what is going on with dat files.

any simple explaination or sugestion of how to work with a dat file is appreciatted.

Im looking for the overall concept of what they are as compared to the text file.

my confusion is that, as we all are familiar with working with text files and doc files. we open and close them in everyday computing,
Im just not used to working with dat files or fully understand why a dat file would be better then saving as a doc file.

TIA


Report Offensive Message For Removal


Response Number 1
Name: wizard-fred
Date: January 3, 2008 at 18:01:11 Pacific
Subject: Txt doc and Dat files using VB
Reply: (edit)
By your description a 'dat' file is a database or random access file. The advantages is that you can add, modify, or delete a record in the file without rewriting all of it. When the file becomes larger you see the advantages. Some study of databases might give you insight of the management of how they handle data.

Report Offensive Follow Up For Removal

Response Number 2
Name: Razor2.3
Date: January 4, 2008 at 19:06:07 Pacific
Subject: Txt doc and Dat files using VB
Reply: (edit)
I did some experimentatiion and found I can very easily save the info as a simple doc file there doesnt seem to be a problem with length here...Am I Right?
Depends. If you're launching MS-Word, then yes (but it's quite sloppy). If you're just saving the text file as a .DOC, then no. Or we could both be wrong; I can't find any documentation on the limits of text files in VB6.

Im looking for the overall concept of what they are as compared to the text file.
Instead of taking binary data and turning them into human readable text, it keeps the data as binary data.

fully understand why a dat file would be better then saving as a doc file.
Well, you're requiring your client to have MS Word installed and operating correctly. That adds overhead, decreases speed, and can leave errant copies of WINWORD.EXE floating in memory if your program crashes.

Compared to text files, the equivalent binary file tends to be smaller; an Integer can be up to 5 bytes in a text file, but will always take up 2 bytes in a binary file. I also suspect binary files have a larger upper limit, but as I said, I can't find any documentation to back up that statement up.

any simple explaination or sugestion of how to work with a dat file is appreciatted.
Instead of Open "whatever" For [Input|Output] As #1 use Open "whatever" [For Random] As #1 Len = Len(Rec) Then, at the module level, add this:

[Private] Type Rec
Name As String * 5
Phone As String * 10 'I suggest you separate
'formatting from data; increase as needed
'if you disagree. Note: All strings must be
'of fixed size.
'Whatever else you store goes here.

End Type

Then, instead of Input #1/Write #1, use Put #1,,/Get #1,,. Easy, no?

EDIT: Sometimes I'm surprised English is my first language...


Report Offensive Follow Up For Removal

Response Number 3
Name: basicdos
Date: January 5, 2008 at 13:41:00 Pacific
Subject: Txt doc and Dat files using VB
Reply: (edit)
Thanks for the replies guys

No im not opening winword at all. I just replace the file extention when the file is created by the open command -with open as .doc instead of open as .txt and the file is created
seems to use the same commands as if i opened a text file

The program worked fine and I accumulated a long list of contact information, then one day it got scrambeled and wouldnt take any more info and I received an end of file message
the program is dependent upon the line count as multiples of each saved file such as every fifth line would be a first name, every sixth line a zip code etc...
so an uneven save of lines made the whole file out of whack.. because I used the line count to save and retreive information and to re-alphabetize the list when new entries were made

:::I Should have said this first:::

"What Im trying to do"... is create a voting program that saves the users choice to a file on the hard drive and im trying to decide the best way or file type to use with visual basic programming to be run on a windows computer.

the text file system was limited by length
...or do you think it was just a programming glitch that took a while to show up?

the doc file system is limited to Windows Word


Ive never worked using dat or bin files etc

I used the text file because they were the easiest for me to understand and work with.

I can work with and learn the dat file, record and array commands Do you think that would be the best choice?, or is there another method You guys sugest?

Thanks for the input


Report Offensive Follow Up For Removal

Response Number 4
Name: wizard-fred
Date: January 5, 2008 at 14:40:02 Pacific
Subject: Txt doc and Dat files using VB
Reply: (edit)
The .txt file is probably limited to the maximum size of the version of the OS. Don't know why you lost sync. I have used BASIC to handle files to about 10 MB in size. All files are bin. Txt files are just a special case. You probably should learn random files next. Fewest changes to your existing programs. You can even convert your existing data.

Report Offensive Follow Up For Removal

Response Number 5
Name: basicdos
Date: January 6, 2008 at 16:30:03 Pacific
Subject: Txt doc and Dat files using VB
Reply: (edit)
Ok, so by working with random files you mean to open the file as random.

please Let me know if i have the following steps right...

create an array
determine its record structure
put info in it
save it as???? a dat file to hard disk same as I would a text file?
and then open it same as i would any other file, for later use?

And this file if undimentioned array should be able to handle as much data as i ever put into it ?

Thanks


Report Offensive Follow Up For Removal


Response Number 6
Name: Razor2.3
Date: January 6, 2008 at 17:32:19 Pacific
Subject: Txt doc and Dat files using VB
Reply: (edit)
Your order's off. You should first create your structure, and make an array of that.

Also, you would open the file to read with the same syntax you used to open the file to write it.

Finally, I suggest you make the first entry specify the amount of data in the file. That way, (a) you know how large to make your array, and (b) you have a (very) crude method of detecting corruption [FileSize / (Len(Rec) + 1) = FirstEntryInFile]. Unless you want to make a self-growing array class. That's possible, too. Even then, the size indicator would be a good idea.


Report Offensive Follow Up For Removal

Response Number 7
Name: basicdos
Date: January 7, 2008 at 17:45:27 Pacific
Subject: Txt doc and Dat files using VB
Reply: (edit)
Thank You Both Very Much

I think Ill do a little reading up and experimenting with the records and arrays


Rob


Report Offensive Follow Up For Removal

Response Number 8
Name: wizard-fred
Date: January 9, 2008 at 21:12:05 Pacific
Subject: Txt doc and Dat files using VB
Reply: (edit)
You don't neec to dimension an array to contain the whole file. In a database or random file you typically only handle one record at a time. A pointer keeps track of the current record.

Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Txt doc and Dat files using VB

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




XP Installed to G?

exessive internet traffic

ZoneAlarm Question. Blocked Connect

Windows Live Messenger Problem

Delete $Uninstall after SP3 updates


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC