Solved

Print ASCII new line character (decimal 10)

Posted on 2004-04-01
7
2,873 Views
Last Modified: 2008-03-10
Hi,

I need to write a txt output file in which each record in terminated
with a ASCII new-line charecter(decimal 10).
Can you please let me know how to get this done using VB functions.

Thanks,
Siva.
0
Comment
Question by:sivavb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Expert Comment

by:dancebert
ID: 10732860
0
 
LVL 9

Expert Comment

by:dancebert
ID: 10732882
Ok, that was a little cryptic.  What you need to do is add the vbNewLine character to the end of your string then write the string to the output file.  For example:

dim s as string
s = "This is my data and that is my newline" & vbNewLine

Do you also need to know how to write the string to an output file?


0
 

Author Comment

by:sivavb
ID: 10732912
Hi ,

I need to print some values in each record of the file and then add a new line charecter at
the end

I doing as follows.Will it serve the puropse ?

Print #FileNum2, iCT_ID; "|"; sRecDate; "|"; sRecTime; "|"; chr(10)

Let me know if there are any issues ?

Thanks,
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 9

Expert Comment

by:dancebert
ID: 10733212
Looks ok to me, but I didn't try running it.
0
 

Expert Comment

by:pyromatt
ID: 10734055
Use;

Print #FileNum2, iCT_ID & "|" & sRecDate & "|" & sRecTime & "|" & vbCrLf

Should work...
Matt.
0
 

Accepted Solution

by:
pyromatt earned 50 total points
ID: 10734103
Btw, if your interested...

vbCrLf = chr(13) & chr(10)

As far as i know, you need to use both 13 AND 10, as 13 goes back to the beginning of the line and 10 goes down a line, so you end up at the very beginning of a new line.


0
 
LVL 5

Expert Comment

by:Cimperiali
ID: 10977389
Option Explicit
'If you need chr(10) only - and not also chr(13)
'you can go also this way
Private Sub Command1_Click()
    Dim sText As String
    Dim theBreak As String
    theBreak = Chr$(10)
    Dim lCounter As Long
    Dim intFree As Integer
    sText = "Put your text" & theBreak
    For lCounter = 1 To 10
        sText = sText & "This is line n° " & lCounter + 1 & theBreak
       
    Next
    'print on file
    intFree = FreeFile
    Open "c:\test.txt" For Binary As #intFree
        Put #intFree, , sText
    Close #intFree
End Sub
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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 (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…
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…
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…
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…

724 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