Results 1 to 15 of 15

Thread: How can i open a file ascii?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    How can i open a file ascii???

  2. #2
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    Huh??

    Open "C:\file.txt" for input as #1

    ?????

  3. #3
    Guest

    Post

    NEVER use #1...

    Code:
    dim MyFile as byte
    Myfile = freefile
    open "whatever" for append as #myfile
    'add stuff to file
    close #myfile
    note: do not declare "Freefile"

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    how can i open it in binary adn show the binary in a textbox with out it getting a error like it does to me and 2 how can i opened a file in hex and dec

  5. #5
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    You'll have to open it in binary, and then convert it to Hex

  6. #6
    Lively Member
    Join Date
    Dec 1999
    Posts
    79

    Post

    What would be the code to do this?

  7. #7
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    Prolly sumptin like:
    Code:
    Dim MyFile as byte
    Dim i as integer
    Dim strBin as string
    Open "whatever" for binary as MyFile
    For i = 1 to LOF(MyFile)
        Get MyFile, i, strBin
        Text1 = Text1 & strBin
        strBin = Hex(Asc(strBin))
        Text2 = Text2 & " " & strBin
    Next
    Close MyFile
    I dunno

    ------------------
    r0ach(tm)

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    here what i did and it not working look

    Code:
    Private Sub Form_Load()
    Dim MyFile As Byte
    Dim i As Integer
    Dim strBin As String
    Dim B
    CommonDialog1.ShowOpen
    
    Open CommonDialog1.filename For Binary As MyFile
    For i = 1 To LOF(MyFile)
    Get MyFile, i, strBin
    Text1 = Text1 & strBin
    strBin = Hex(Asc(strBin))
    Text2 = Text2 & " " & strBin
    Next
    Close MyFile
    End Sub

  9. #9
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    Oops, my mistake.
    You should put
    MyFile = freefile
    before opening the file. sorry

    ------------------
    r0ach(tm)

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    i just got a voer flow on
    For i = 1 To LOF(MyFile)

  11. #11
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    change
    Dim i as integer
    to
    Dim i as long.

    I just quickly threw that together. Don't trust it.

    ------------------
    r0ach(tm)

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    now im getting a invaild call or arugment on
    strBin = Hex(Asc(strBin))

  13. #13
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    Works for me!
    What's the value of strBin, when you get the error??

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    nothing

  15. #15
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    change
    Dim strBin As String
    to
    Dim strBin As String * 1

    be prepared to wait a while though

    ------------------
    r0ach(tm)

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