|
-
Nov 20th, 2002, 09:37 AM
#1
Thread Starter
Frenzied Member
Error on binary file read? FIXED
I have a very simple program:
VB Code:
Private Sub Command1_Click()
Open "c:\temp\my.txt" For Binary Access Read As #1
sDATA = Space$(LOF(1))
Get #1, , sDATA
MsgBox sDATA
End Sub
The file exists OK.
LOF(1) shows a length of 50.
But on the GET line, I receive an error of:
" Run time error 458
Variable uses an automation type not supported in Visual Basic "
Any ideas why?
Last edited by JordanChris; Nov 20th, 2002 at 09:48 AM.
-
Nov 20th, 2002, 09:40 AM
#2
Retired VBF Adm1nistrator
Just try this
VB Code:
Open "c:\someFile.txt" For Binary As #1
Dim strBuff As String: strBuff = Space(Lof(1))
Get #1, , strBuff
Close #1
strBuff would then contain the contents of the file
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Nov 20th, 2002, 09:48 AM
#3
Thread Starter
Frenzied Member
THANKS.
I didn't have the CLOSE, so I wonder if I had previously opened it and it didn't like doing so again?
-
Nov 20th, 2002, 09:50 AM
#4
I wonder how many charact
It wasn't about Closing... You needed to declare sData explicity... as plenderj did... otherwise, the compiler uses a variable type that it thinks it should, and obviously it picked the wrong type for the job..
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
|