Solved

Writing to a text file

Posted on 2006-11-22
2
194 Views
Last Modified: 2010-04-30
Hi,
I am trying to write a string to a text file.  I am using:
WriteLine(1, strgName)
Is there another way to write a string to a text file without the parenthesis showing?
Each strgName is supposed represent a data record, so I would to ensure a CR is present also.
Any help would be appreciated.
0
Comment
Question by:VBStudent
2 Comments
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 17997796
WriteLine 1, strgName

As long as you have a space after the WriteLine you should be fine.

If you want CR before the 1 and or anything else then just add it in.

Im assuming that the strgName is a variable which you have not shown us and that 1 is a numerical value, if you want the 1 to be a string then just put "" around it ie "1"

As for the CR, I think you will have to have quotes around that since it is a string.

Maybe you can show us how you want this to be displayed when it is written to the text file and also what strgName is etc
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 17998025
This will write an array as text lines to a file:

Sub WriteFile(strArray() As String)
    Dim f As Integer
    Dim i As Integer
   
    f = FreeFile
    Open "C:\MyPath\MyFile.txt" For Output As #f
        For i = 0 To UBound(strArray)
            Print #f, strArray(i)
        Next i
    Close #f
End Sub

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
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…

707 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

15 Experts available now in Live!

Get 1:1 Help Now