CodeBlue
CodeBlue

Reputation: 15399

How to correctly write the contents of a Byte array to a file in VB6?

I have a variable declaration as follows -

Public CA() As Byte

When I want to write the contents of this to a file, I do the following -

myStr = StrConv(CA, vbUnicode)        
intFileHandle = FreeFile
Open "myFile.txt" For Output As #intFileHandle
Print #intFileHandle, myStr
Close #intFileHandle

However, I am not sure whether this is the correct way. Could you recommend a correct way to write the contents of the byte array to the file?

Upvotes: 1

Views: 6662

Answers (1)

Chris McCall
Chris McCall

Reputation: 10407

dim fnum As Integer
fnum = FreeFile()
Open "myFile.txt" For Binary As #fnum
Put #fnum, 1, CA
Close fnum

Upvotes: 4

Related Questions