Solved

Writing to a text file

Posted on 2006-11-22
2
200 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
[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
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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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…
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.
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…

687 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