•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 391,905 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,597 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 7605 | Replies: 1
![]() |
In Visual Basic 6 I have written a program to read and write to a file. It works fine. Now I have to do the same for binary data since the information I write to the file has end-of-line and return characters. For instance, when I write to the file, the data looks like this:
"3
34"
Because there is a break in the data. In debug mode, the text data has two boxes where the end-of-line and return characters go.
Anyway, does anyone have any example code of binary level reading and writing to and from a file?
"3
34"
Because there is a break in the data. In debug mode, the text data has two boxes where the end-of-line and return characters go.
Anyway, does anyone have any example code of binary level reading and writing to and from a file?
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
The character codes for that are vbcr and vblf (also vbcrlf) which translate to chr(13) and chr(10) (those are carriage return and line feed). So, if it would be easier for you to merely check for an occurance of either of those in a string using instr, and replacing the offending character with the replace function, that might be an easier solution for you. However, if you want to leave the file completely unchanged, and merely write the file as it is with binary:
Let me know what you come up with.
Dim B() As Byte
Dim srcFile as string
dim destFile as string
' /* Change This To your File */
srcFile = "c:\somefile.exe"
destFile = "c:\destination.exe"
Open srcFile For Binary Access Read As #1
ReDim B(LOF(1) - 1)
Get #1, , B
Close #1
open destfile for binary access write as #1
put #1, , B
close #1Let me know what you come up with.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
- Get data out of excel file stored as an image (MS SQL)
- writing students data to a text file (Assembly)
- Listview Data to XML or file (VB.NET)
- Binary data in app.config (C#)
- How to load binary content of a .class file? (Java)
- empty or delete data index file in temp internet files (Windows NT / 2000 / XP / 2003)
- problems with reading random access line from a file (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: using the clipboard
- Next Thread: RmDir and MsChart Have Problems in XP -Pls Help



Linear Mode