
Random access files - having and finding multiple types of record in one file
Your second file only has one record type -- just more than one record.
Create a UDT:
Type udtMsg
Message * 1024 As String ' or whatever length works for you
ShowTime As Double
End Type
Use Get to read the open file:
Dim StoredMsg As udtMsg
Get #1, RecordNumber, StoredMsg
The message is in StoredMessage.Message
The time is in StoredMessage.ShowTime
Random access storage requires fixed length records. That allows you to read any
record by recpord number, so you need not read all the ones that precede it.
This is all covered in my book -- Visual Basic 5 Interactive Course from the
Waite Group Press.
>My boss wants a GUI to send a series of messages to a list of people on
>the network. He also wants to have more that one list at a time having
>messages sent to them. For memory conservation, I'd like to be able use
>random file access on each list that's being used. The way that the
>list files are designed so far (though it may change if I have to) is a
>listing of all names followed by a listing of all messages to be sent
>with the time that the messages are to be displayed.
>
>What I need to know is HOW to read multiple record types in a file that
>has more than 1 record type (below is an example of what the file looks
>like). For example, once message 1 has been displayed for it's given
>period of time, then message 2 would be displayed. I want to go
>straight to message 2 without having to re-read the entire file. I hope
>this makes some sense. I've read the VB Books Online (Online Manual)
>and the FAQs, but all I've found so far is that there must be 1 record
>type in the file :(
>
>Hope someone can help me... (and this program is NOT for spam)
>
>(example list file)
>[NAMES]
>name 1
>name 2
>name 3
>name 4
>
>[MESSAGES]
>message 1, message time
>message 2, message time
>message 3, message time
>message 4, message time
>(EOF)
>--
>/********************************\
>|* I'm a wizard, not an English *|
>|* major. Ignorre my speling *|
>|* mistaks *|
>\********************************/