Solved

Print ASCII new line character (decimal 10)

Posted on 2004-04-01
7
2,864 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

744 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

11 Experts available now in Live!

Get 1:1 Help Now