Results 1 to 5 of 5

Thread: open in sub, get in function HELP!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    180

    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?

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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")?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    180

    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.

  5. #5
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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?????

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width