Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to open hexa file

Status
Not open for further replies.

AIP

Programmer
Jun 1, 2005
2
ID
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.

thanx.

aip
 
Here are the typical ways to open a file for I/O:

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.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top