File I/O

Dim FileNum As Integer
Dim Size As Long
Dim Data() As Byte

FileNum = FreeFile()
Open FileName For Binary As #FileNum
Size = LOF(FileNum)
ReDim Data(Size - 1)
Get #FileNum, , Data
Close #FileNum

If you then want to use this data as text (e.g., in a TextBox) you can use the following:

TextBox.Text = StrConv(Data, vbUnicode)

Please note that you can NOT reliably store binary data in a string. You will get corrupted data on non SBCS systems like Japanese, Korean, and Chinese windows. Additionally, you can not show data containing Nulls in a textbox. It will be truncated at the first null character.

For more Information, contact us via email at info@earlsoft.co.uk.