Solved

Print ASCII new line character (decimal 10)

Posted on 2004-04-01
7
2,869 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
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MsgBox 2 54
VBS file using code from 2nd file (txt or vbs) 4 36
MS SQL store procedure to calculate and return result 6 58
VB6 - Convert HH:MM into Decimal 8 54
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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

772 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