Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
274 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Accepted Solution

by:
sakuya_su earned 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

877 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