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
263 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 36
change vba from autofit to 13.5 width? 4 28
vb6 connector to SQL Server 2 34
Excel VBA, find a string in a column, update a cell 7 65
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

911 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