To add to QbasicKing's example...
If you do it like he specifies there's no way of organizing your data. Lets say you have some game data---weapons for instance. Each weapon has the same kind of attributes, but the attributes are different, which makes each weapon unique. Here's a basic example:
First we make a record template:
Type weapondata
wName As String * 15
wType As Integer
wDamage As Integer
wSpeed As Integer
End Type
Each record contains a weapon name, type, damage and speed. Now lets take this record template and store it into a word, making it an object. Underneath the object are the record fields called Name, Type, Damage and Speed which are used as Weapon.keyword (i.e. Weapon.Name). First lets DIM our Weapon object:
Dim Weapon As weapondata
Now we should open the data file for the info to be stored in. In QBasicKing's example there was no order to the data being written. When you use a Type, it allows you to keep data consistent as records. i.e. record one would have a weapon name, type, damage and speed. The way we open the file is to take the record object (Weapon) and use its length as the record length for the file as follows:
Open "Weapons.dat" for Random Access Read Write as 1 Len=Len(Weapon)
Now lets say you have an existing Weapons.dat and want to find out how many weapons there are in the file. Take the length of the file and divide it by the length of Weapon, which tells us exactly how many weapons (records) are in the file:
MaxWeapons = LOF(1) / Len(Weapon)
Now that we have this information we can read all weapons into an array, or read them at will. We simply specify which record (a number between 1 and MaxWeapons) and GET it:
Get 1, recordnumber, Weapon
This reads data from the corresponding record into Weapon.Name, Weapon.Type, Weapon.Damage and Weapon.Speed
Likewise, if you want to write to a record simply specify the recordnumber to write data to. If you want to create a new record simply write to MaxWeapons + 1. Be sure to recalculate MaxWeapons after writing a new record.
Weapon.Name = "Cracked Mace"
Weapon.Type = 1 '1=blunt, 2=slash, 3=pierce, etc.
Weapon.Damage = 12
Weapon.Speed = 5
Put 1, recordnumber, Weapon
What you end up with is a file containing records like a database. Each record is the same length. Weapon.Name is stored as 15 characters regardless if it is less than that. When you read in Weapon.Name you have to do RTRIM$(Weapon.Name) to remove spaces from the end, because it will be 15 characters.
The way QBasicKing described would write indescriminantly to the random access file, as if you were writing to a data file using sequential file writing (i.e. Open myfile for Input/Output). Random access files are powerful because they can be set up to hold huge amounts of data in an orderly fashion (records), and data can be retrieved super fast. If I were writing a game, I'd sure be using random access files instead of plain ole sequential data files. You can keep track of your data easier and there's no parsing at all.
Hope I've helped. Good luck.