Solved

To write string date (record) into a file that has NO CR/LF, ie. in binary mode. or stream file

Posted on 2006-07-12
7
262 Views
Last Modified: 2012-08-13
I have a program that write data in line-by-line mode that use the following code
dim ch_o as integer
dim data_str as string

 ch_o = freefile()
 open "out.txt" for output as #ch_o

 data_str = "1234 56 abcd"
    print #ch_o, data_str
  etc.

this way, the data is writen in to file "out.txt", and create CR/LF at the end of each line
written.

Now, I have a need to write the datafile, that will be continous char by char,  NO CR/LF
but each data line could be a variable length.  (I suppose I can write one byte at a time).

  1. How do I open that file  (for output, or for append), must have some file type?
  2. what vb6 syntax I need to use?

     for i = 1 len(data_str)
        write ch_o, mid(data_str,i,1)
     next

 I am sure VB6 can take care of this type of issues.  Please help me.

thanks

mshox1

0
Comment
Question by:mshox1
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 10

Expert Comment

by:sakuya_su
ID: 17095702
you can do open *** for binary output as **
0
 

Author Comment

by:mshox1
ID: 17095759
Sakuya,  Let me make sure I understand it correct.  are you saying I should do the following coding:

    open "my_output.dat" for binary output as #ch_o

  '  this will open the file "my_output.dat" for binary, and output mode

  to actual write the data into the file.  what I should do?
     assume we have data_str = "abcdef"
     print #ch_o, data_str
     print #ch_o, "12345"

   the data file will have "abcdef12345"   after the above 2 statement?

 Please verify, and if you can give some code example in VB6 will even better.

thanks

mshox1
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17096551
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 10

Accepted Solution

by:
sakuya_su earned 500 total points
ID: 17096613
yeah liek that one
0
 

Author Comment

by:mshox1
ID: 17096642
to all:

do you know if there is a 'dump' file utility program that can display the
binary code (either ascii, or hex) value for a given file.

I need to see what the output looks like (i.e. if crLF) are NOT written.

thanks

mshox1
0
 
LVL 19

Expert Comment

by:Rimvis
ID: 17097564
Search Google for "hex editor" :)
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17102435
This is the one I use:
http://www.hhdsoftware.com/free-hex-editor.html

You can also open it in notepad if its ascii data, just dont save it
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now