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
265 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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

821 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