Results 1 to 3 of 3

Thread: Reading a file a byte at a time

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    8

    Exclamation Reading a file a byte at a time

    Hi everyone:
    I am trying to read from a file one byte at a time because I need to take part of the existing bytes in a file and then save it in a new one. I am including here how I am trying to do it but it seems it does not work ????


    Private Sub Command2_Click()
    Dim size As Long
    Dim myByteArray() As Byte
    Dim Temporary As Byte


    Open "c:\test.wav" For Input As #1
    For i = 1 To i = 1000
    Input #1, i, Temporary
    myByteArray(i) = Temporary
    Next
    Close #1

    Open "c:\test1.wav" For Output As #2
    For w = 1 To w = 1000
    Write #2, w, myByteArray(w)
    Next
    Close #2


    End Sub


    **** any suggestions will be very appreciated !!!!

    Thanks

    Rene

  2. #2
    jim mcnamara
    Guest
    Code:
    dim i as Byte
    open "c:\test.wav" for binary as #1
    Do while not Eof(1)
        get #1,,i
       ' i is now one byte of data 
    Loop
    Close #1

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Try:
    VB Code:
    1. Private Sub Form_Load()
    2. Dim iBuff As Byte
    3.  
    4. Open "C:\test.wav" For Binary As #1
    5.     Get #1, , iBuff
    6. Close #1
    7.  
    8. MsgBox iBuff
    9. End Sub

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