| | |
VB 6.0. Creating a file for random access
![]() |
•
•
Join Date: Sep 2004
Posts: 3
Reputation:
Solved Threads: 0
Hi, I'm new around here & newish to VB 6.0 as well! :cheesy:
I'm using VB 6.0 to create a random access file, which has 2 fields per record . I know that all the records must be of equal length, but am wondering if there is a practical limit to the total number of bytes (or characters) that can be stored in a record of such a file.
If there is a maximum number here, what is it, please?
I'm using VB 6.0 to create a random access file, which has 2 fields per record . I know that all the records must be of equal length, but am wondering if there is a practical limit to the total number of bytes (or characters) that can be stored in a record of such a file.
If there is a maximum number here, what is it, please?
•
•
Join Date: May 2004
Posts: 40
Reputation:
Solved Threads: 0
Though I use PowerBasic for windows instead of VB, i'm sure the record
length for random files is quite large as it is with PB. Of course it should
be kept in mind that many times the larger the record, the more likely
wasted space is increased which is inherent in random (i.e. fixed length)
files especially when there are name. address. city, comment fields etc.
length for random files is quite large as it is with PB. Of course it should
be kept in mind that many times the larger the record, the more likely
wasted space is increased which is inherent in random (i.e. fixed length)
files especially when there are name. address. city, comment fields etc.
•
•
Join Date: Sep 2004
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Buff
Though I use PowerBasic for windows instead of VB, i'm sure the record
length for random files is quite large as it is with PB. Of course it should
be kept in mind that many times the larger the record, the more likely
wasted space is increased which is inherent in random (i.e. fixed length)
files especially when there are name. address. city, comment fields etc.
I've tried progressively increasing the record length, and VB 6.0 didn't complain! It will accept any value I'm likely to require, without hitting the ceiling, so I'm happy about that!
Agreed, random files can be quite wasteful on space. The two fields I've created each need to hold strings containing anything from 1 to 140 characters, so I'm compelled to set their lengths to the latter value. In an extreme case, a single ASCII character padded with 139 blanks would certainly not be economical!!
I don't know what alternatives exist to the use of random files, in order to save disc space. Sequential files are definitely out! I had wondered about binary files, but I read somewhere that these are generally used where the files are not going to be read by humans. To me this implies that there could be problems if I try to use them to store ordinary text.
Using a database is a possibility. VB 6.0 Pro version provides a form of database (Microsoft Access) ready built-in, but it appears to be a sawn-off version of the real thing. Have tried it out, but it will only allow me to search for a complete record. I have not persuaded it to look for a sub-string within a record. This is something that is very easy to do when my stuff is stored in one or more random files.
Ah well, I guess you pays your money & takes your choice!
Last edited by ArchiMedes; Sep 6th, 2004 at 9:49 pm. Reason: Afterthought!
•
•
Join Date: May 2004
Posts: 40
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by ArchiMedes
Thanks, Buff.
I had wondered about binary files, but I read somewhere that these are generally used where the files are not going to be read by humans. To me this implies that there could be problems if I try to use them to store ordinary text.
LOL.
Besides, you can treat any file as a binary file.In fact when you get right down to it, all files are binary files in one sense.
I would say that if the maximum length is only 140 then random files would be
good. That is a relatively small record size so the computer will read the records pretty fast and with today's large hard drives it would amount to only 14 Mb if you have 100,000 records.
•
•
Join Date: Sep 2004
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
I would say that if the maximum length is only 140 then random files would be good. That is a relatively small record size so the computer will read the records pretty fast and with today's large hard drives it would amount to only 14 Mb if you have 100,000 records.
I'm writing a Spanish programme designed to assist English speakers to learn the language. The user can create any Topic he choses, (eg nouns, verbs, adjectives, notes of any description, extracts from a Spanish book, etc). For each Topic, a random file is created. Within a Topic, each Entry corresponds to a Record containing 2 string fields of 140 characters each, to hold respectively the English text & a corresponding Spanish version. ie, 280 characters per record.
It's impossible to predict how many Topics the user will create, or how many Entries he will place in each (depends upon how keen he is!
), but I envisage say, up to 100 such random files, with an average of 400 records in each. Anything in excess of that I would regard as exceptional!Judging from what you say, although each record is 280 bytes, rather than the 140 I quoted previously, this level of usage should still scarcely make a dent on a large hard drive. (Specifically, 11.2 Mb, unless I've overlooked some other requirement). I guess there might be a problem with older machines where space is at a premium. That doesn't worry me unduly, 'cos I'm not distributing it for sale - just passing it on to a couple of unsuspecting family members!
The programme has various learning features, including a search facility & a test, with 10-50 randomly chosen questions, optionally against the clock, and a log file to which the test details, results & scores can be written. I have already got the programme up & running in QBasic, but I thought it would be fun & a challenge to create it again in Visual Basic, at which I am a raw beginner. It's proving to be an excellent way of learning Visual Basic. The more mistakes I make, the more I learn! It felt quite weird at first. In QBasic, you normally get the core code working first, then make the interface look pretty afterwards. With VB, it's the other way round. For me, that was the hardest part to swallow & took some getting used to! :eek: You've got to have at least a hazy idea of where you're going before you start to draw your user interface. At the time, seemed like trying to stick the wallpaper up first, then build the house afterwards.
Thanks for the help you've given me, Buff. I really appreciate it.
![]() |
Similar Threads
- Forms in Random access files (Visual Basic 4 / 5 / 6)
- random access file and creating an index file (C)
- Creating a Address Book using Random Access Files (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: multi select list box error HELP
- Next Thread: random acces file
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows





