VBGamer |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RE: Length Adam Hoult (4 replies, 0 views) (2000-May-6) To add a little to this, there is actually no need to set the length of the string, however space can be wasted if you don't. It all depends on how you read/write the file. When you write a variable length string using "put" a length descriptor is also written. Most people try to actually tell the get function where to read the data from, but actually (i dont know if you are doing this) there is no need. Example :
Dim lngVal as Long
Dim intVal as Integer
Dim strVal as String
lngVal = 2982302
intVal = 2356
strVal = "This is a test string so there"
Open "MyFile.dat" for binary access write as #1
put #1, , lngVal
put #1, , intVal
put #1, , strVal
Close #1
'File is now written, blank the vars and read back in in the same order
lngVal = 0
intVal = 0
strVal = ""
Open "MyFile.dat" for binary access read as #1
get #1, , lngVal
get #1, , intVal
get #1, , strVal
Close #1
msgbox strVal
'Output is This is a test string so there
If you are doing it like this, try pasting the code here so we can help a little more.
HTH (and sorry to contradict you lucky !!)
Adam
|