Solved

Print ASCII new line character (decimal 10)

Posted on 2004-04-01
7
2,871 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 70
MsgBox 4 71
Excel VBA - Run Time error '1004' Application-defined or object-defined error 4 371
backup program with robocopy 6 75
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

730 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