|
-
Oct 9th, 2002, 07:20 PM
#1
Thread Starter
Addicted Member
strings in binary files
is there any reason why i can't use 'Get' to pull a string variable off of a binary file? Or maybe I'm just doing it wrong...
Code:
Dim s As String
Open "c:\windows\desktop\file1.dat" For Binary As #1
Put #1, 1, "chicken!"
Get #1, 1, s
Close
MsgBox s
the message box should display "chicken!" however I see nothing :(
To understand recursion, one must first understand the concept of recursion.
-
Oct 9th, 2002, 07:25 PM
#2
Thread Starter
Addicted Member
oops, i meant to post this in the general forum o.o Oh well, the code is for my map editor so.. :D
To understand recursion, one must first understand the concept of recursion.
-
Oct 9th, 2002, 07:38 PM
#3
Good Ol' Platypus
If you closed, then reopened before the Get statement it would work, I think. If this works, it's because VB saves the data at the Close statement. I can't think of anything else, other than the fact that Get and Put get data from the current part of the stream, but I think you got that already with the 1, 1.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 9th, 2002, 07:47 PM
#4
Thread Starter
Addicted Member
no, that's not the problem. doesnt work when i close and re-open either
To understand recursion, one must first understand the concept of recursion.
-
Oct 9th, 2002, 08:42 PM
#5
Hyperactive Member
I've always hated using the 'Open' statement! The FileSystemObject is a lot more efficient and easier to use (just import the 'Microsoft Scripting Runtime' reference). Its perfect for file manipulation, and reading/writing binary and plain-text files!
-
Oct 9th, 2002, 09:41 PM
#6
Thread Starter
Addicted Member
how do you use this to write binary files?
To understand recursion, one must first understand the concept of recursion.
-
Oct 10th, 2002, 11:03 AM
#7
Frenzied Member
Try:
Code:
Dim s As String
Open "c:\windows\desktop\file1.dat" For Binary As #1
Put #1,, "chicken!"
s=Space(len("chicken!"))
Seek #1, 1
Get #1, , s
Close #1
MsgBox s
-
Oct 11th, 2002, 04:12 AM
#8
Retired VBF Adm1nistrator
'Hu Flung Dung' - The FileSystemObject is anything but efficient.
It is a load of extra overhead for completing simple File IO operations.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|