open in sub, get in function HELP!
I have a sub that opens a file as binary.
In that sub i have a loop that will call a function, and the function looks inside file, and returns a value. Well its not working, the function doesnt know that the file is open. kinda like this:
Code:
Public Sub x()
....
Open (file) for Binary As #1
For i = 1 to 10
arr(4) = Grabit(arr(1), arr(2), arr(3))
Next
Close #1
....
EndSub
Function Grabit(start, num, kind) as string
Select Case Kind
Case "Word"
Get #1, start, String
EndFunction
well its quick and dirty example, but you get the point. Is it possible?
Re: open in sub, get in function HELP!
does your function "know" all the values you are using in the Sub that opens the file? (especialy "#1")?
Re: open in sub, get in function HELP!
For one thing, Get #1, start, String won't work (String is a reserved word). And there's no End Select. And you have to set Grabit equal to whatever it's supposed to be returning.
Once you clean up all the obvious errors, using the Get statement in the function should work.
Re: open in sub, get in function HELP!
well i didnt copy+paste the code in, it was WAY to long to do so, so i just did a quick "off-the-top-of-the-head" sample to get the point across. I know there are a bunch of errors in the sample code, and it wouldnt compile.
Re: open in sub, get in function HELP!
So how do you expect help with code that you give that is incorrect to correct a problem with code that you do not show?????