Solved

Writing to a text file

Posted on 2006-11-22
2
198 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

735 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