Solved

Writing data to a text file

Posted on 2003-11-18
3
1,016 Views
Last Modified: 2010-05-01
I am trying to write data to an output file.  However, when I open output.txt to view my data, there is nothing written.  Here is the section of my code that is writing to the file.  What am I doing wrong, and why is it not writing any data?

Open ("c:output.txt") For Output As #2
   
For j = 1 To UBound(lines)
    str2 = str2 + getField(j, 2) + "|" + getField(j, 4) + vbCrLf
    Print #2, str2
    frmTest.Text1.Text = str2
Next
Close #2
0
Comment
Question by:jennifere
[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
3 Comments
 

Expert Comment

by:enari
ID: 9773259
Hi!

Your code is correct to write a file.
Which leads me to beleive that your str2 does not have any value.

If you change str2 = "testing my file" , you will see "testing my file" in the output.txt file,

however does:
"lines" have a value and is it greater than one ?
does getField(j,2) have a value?

you can find out by doing a "debug.print getfield(j,2) " and so on.

0
 
LVL 9

Accepted Solution

by:
TooKoolKris earned 125 total points
ID: 9773481
Open ("c:output.txt") For Output As #2

This statement is not a correct path statement it should have a backslash in the path like this:

(c:\output.txt") you forgot to add the "\"
0
 

Author Comment

by:jennifere
ID: 9773649
I have modified the code to your suggestion in my last question, because this one was not working for me.  I knew it was something simple I was overlooking.  That explains what I was doing wrong...  Thanks again.  
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

734 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