Click to See Complete Forum and Search --> : How can i open a file ascii?
XxEvilxX
Jan 15th, 2000, 12:52 AM
How can i open a file ascii???
r0ach
Jan 15th, 2000, 12:56 AM
Huh??
Open "C:\file.txt" for input as #1
?????
NEVER use #1...
dim MyFile as byte
Myfile = freefile
open "whatever" for append as #myfile
'add stuff to file
close #myfile
note: do not declare "Freefile"
XxEvilxX
Jan 15th, 2000, 02:40 AM
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
r0ach
Jan 15th, 2000, 02:43 AM
You'll have to open it in binary, and then convert it to Hex
markwestcott
Jan 15th, 2000, 02:47 AM
What would be the code to do this?
r0ach
Jan 15th, 2000, 02:56 AM
Prolly sumptin like:
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)
XxEvilxX
Jan 15th, 2000, 03:19 AM
here what i did and it not working look
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
r0ach
Jan 15th, 2000, 03:36 AM
Oops, my mistake.
You should put
MyFile = freefile
before opening the file. sorry
------------------
r0ach(tm)
XxEvilxX
Jan 15th, 2000, 03:44 AM
i just got a voer flow on
For i = 1 To LOF(MyFile)
r0ach
Jan 15th, 2000, 04:01 AM
change
Dim i as integer
to
Dim i as long.
I just quickly threw that together. Don't trust it. ;)
------------------
r0ach(tm)
XxEvilxX
Jan 15th, 2000, 04:19 AM
now im getting a invaild call or arugment on
strBin = Hex(Asc(strBin))
r0ach
Jan 15th, 2000, 04:37 AM
Works for me!
What's the value of strBin, when you get the error??
XxEvilxX
Jan 15th, 2000, 04:54 AM
nothing
r0ach
Jan 15th, 2000, 05:19 AM
change
Dim strBin As String
to
Dim strBin As String * 1
be prepared to wait a while though
------------------
r0ach(tm)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.