Results 1 to 4 of 4

Thread: Open binary file

  1. #1
    Guest
    I try to open a binary file by using code:

    open "a.bin" for binary as #1
    while not eof(1)
    msgbox (asc(input (1, #1))
    wend
    close(1)

    but I found that, most of the value print out was 0 (what it should be like 254, 238, 221 etc, but the value 255 was able to print out!), I don't know why, could someone able to help me?

  2. #2
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662

    Arrow

    That method only works with ascii files.
    I fixed your code to work with binary files. Fully commented.

    The new code can be found at http://agent_153.tripod.com/binary.html

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    Ouch....

    Use a byte array!

    "Get" the whole lot to a dynamic array of bytes. Then if you want to look at them loop through them as you like
    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  4. #4
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    Thanks for the input, paul. I think that would make the code bigger, but the file would only need to be open while filling the array. I'll write a second routine that does it that way and then benchmark it.

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