hi,
i am new in vb. i want to open a file name as c:\temp\aaddmmyy.zzz which a sequential file containing hexa values. how to open this file? i also want to write value of this file to another file. how to write it.
Const FileName as String = "C:\temp\aaddmmyy.zzz" 'your file
Dim TextLine as String 'to hold data read from file
Dim FilePointer as Long 'to maintain position in file (Binary only)
1.)
Open FileName for Input as #1 'open to read text
Line Input #1, TextLine 'read one line, store in var
2.)
Open FileName for Output as #1 'open to write text
Print #1, MyNewData 'write new info into file
3.)
Open FileName for Append as #1 'open to write text, adds to EOF
Print #1, MyNewData 'writes to end of file (EOF)
4.)
Open FileName for Binary as #1 'open for Read/Write
Put #1, FilePointer, MyNewData 'write new info
Get #1, FilePointer, TextLine 'this gets one character
unless TextLine is a fixed-length string, in which case it reads the same number of characters as the length of TextLine. FilePointer is incremented automatically, based on how many characters are read.
In general, you should only have to use Binary if you may want to read/write non-displayable characters (like in a hex-editor), because Binary will read true ASCII characters, where the others will interpret null characters (&H00) as spaces (&H20), among other undesirables.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.