I have a field in a table that contains the full path to BPF files.
How can I show the contents of these ANSI encoded files in a textbox on a form?
When I read the contents of the file in vba, and set the textbox, it remains empty.
If I open the file in notepad and save it in UTF-8 , then I can read them and set a textbox to show the contents.
I was thinking of using a function in on-current event of the form to save a temp copy of the file in utf-8 encoding, then read the temp file.
But I couldn't find a way to save a file with a specific encoding.
The code that I use to read them :
Some info about BPF files:
BPF files are special files written in NC language to talk to 5 axis manufacturing machines. They are ANSI encoded and they need special editors to edit the contents.
If you open them in notepad you will see something like this: But even showing this in a textbox, suits us fine.
How can I show the contents of these ANSI encoded files in a textbox on a form?
When I read the contents of the file in vba, and set the textbox, it remains empty.
If I open the file in notepad and save it in UTF-8 , then I can read them and set a textbox to show the contents.
I was thinking of using a function in on-current event of the form to save a temp copy of the file in utf-8 encoding, then read the temp file.
But I couldn't find a way to save a file with a specific encoding.
The code that I use to read them :
SQL:
Public Function ReadTextFile_All(ThisFile As String) As String
Dim FSO As New Scripting.FileSystemObject
Dim txtStream As TextStream
If Not FSO.FileExists(ThisFile) Then Exit Function
Set txtStream = FSO.OpenTextFile(ThisFile)
ReadTextFile_All = txtStream.ReadAll
txtStream.Close
Set txtStream = Nothing
Set FSO = Nothing
End Function
Some info about BPF files:
BPF files are special files written in NC language to talk to 5 axis manufacturing machines. They are ANSI encoded and they need special editors to edit the contents.
If you open them in notepad you will see something like this: But even showing this in a textbox, suits us fine.
Attachments
Last edited: