-
Currently in my project, I am using Read and Write. This is far too slow when it comes to saving stuff cos i have to rewrite the file again and my file is huggee. my file looks kinda like this:
"part1", "secondbit", "thirdbit", etc
"walrus", "bigman", "mad"
will using the Put statement make it possible to change a line in my file without rewriting the file again?, and how would i read the line again?
i want all the data being read from the file to be stored into arrays i.e. FirstPart(1)="part1"
FirstPart(2)="walrus"
please help
-
is each line of your file related to each other in a way that would let you define a UDT?
-
Sorry, whats a UDT? Im kinda new to visual basic :)
-
UDT
A UDT is a User Defined Type. Here's how you make a UDT:
Private Type MyType
Name as String
Age as Byte
Height as Byte
Weight as Long
End Type
You can now define a variable using this type. Example:
Dim Person As MyType
Person.Name = "Grandpa"
Person.Age = "100" :D
Person.Height = 72 'inches :rolleyes:
Person.Weight = 399 'pounds :eek:
You get the picture now right?
Hope this helps,
Drew
-
thanx verrry much for that :) :), but how would u 'put' that in a file and 'get' that data back into arrays? like name(), age() etc
-
'define your UDT
type person
dim firstname as string * 10
dim lastname as string * 10
end type
'create and instance of your UDT (person)
dim p as person
'open a file in random
open "yourfile" for random as fp len = len(p)
'len = len(p) defines the length of each record in the file
'firstname and lastname use fixed length strings so each
'record you write is the same length, and then can write
'and retrive records in the middle of a file
get fp, 5 , p
'would read the 5th record of your file into the UDT var p
'leaving out the record number, i think, writes to the end
'file, but you might want to check on that
put fp, 5, p
'would write your UDT var p to the 5th record in your file
'then if you need to put it into a array
'but trim off the spaces (fixed len strings)
array(0) = trim$(p.firstname)
array(1) = trim$(p.lastname)
any help???
-
thanxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx veryyyyyy muchhhh :) :) :) i really needed that