Results 1 to 5 of 5

Thread: Open files binary (solved) and sending it.. then writting it again (PROBLEM)

  1. #1

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172

    Open files binary (solved) and sending it.. then writting it again (PROBLEM)

    VB Code:
    1. Open App.Path & "\temp.bmp" For Binary Access Read As #iHandle
    2.  Do Until EOF(iHandle)
    3.   Get #iHandle, , a$
    4.    packets = packets + 1
    5.    DoEvents
    6.  Loop
    7. Close #iHandle

    what am i doing wrong? it seems to be stuck ina loop (the packets thing is just a test)
    Last edited by Ultimasnake; Apr 23rd, 2003 at 07:43 AM.
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    the following works fine. you need to lose the loop and dimension a as either a byte array or a fixed length string
    VB Code:
    1. Dim a(20000) As Byte
    2. Dim iHandle As Integer
    3.  
    4. iHandle = FreeFile
    5. Open App.Path & "\new.xls" For Binary Access Read As #iHandle
    6.   Get #iHandle, , a
    7.    DoEvents
    8. Close #iHandle

  3. #3

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    ok so the loop isnt there anymore.. is there anyway to detiremine how many of those things are used? i have to read it all as binary and then send it part by part to a client program

    i tried UBound(a) with "a" declared as A() as byte
    but i get a supscript out of range :S
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  4. #4
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    ??? it will get EVERYTHING. If you want to read it in chunks you could do something like

    Dim bBytes(2047) as byte '2048 bytes or 2K

    Open File for Binary As #1
    Do Until LOF(1) = Loc(1) Or EOF(1) 'loc(1) if the current byte, lof(1) is the length of the file

    Get #1, , bBytes
    'now do something with bbytes
    'then continue looping
    loop
    Close #1
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  5. #5

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    Ok that works buggyprogrammer.. any tips on how to write it again? cant seem to make that work perfectly this is what i have now

    VB Code:
    1. Open App.Path & "\tmp.bmp" For Binary Access Write As #iHandle
    2.  
    3.  
    4. 'every time i get a raw package i will do this (in a sub)
    5.   strmessage = GetStringFromBuffer(dpnotify.ReceivedData, lngOffset)
    6.  
    7.   Put #iHandle, , strmessage
    8.  
    9.  
    10. 'when i have recieved all packages (that i sent in a command that tells the client he will be recieving raw picture data)
    11. Close #iHandle

    but the filesizes arn't even equal :s
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

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