?
Solved

Writing to a text file

Posted on 2006-11-22
2
Medium Priority
?
201 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 2000 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

Technology Partners: 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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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