[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1025
  • Last Modified:

Writing data to a text file

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
jennifere
Asked:
jennifere
1 Solution
 
enariCommented:
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
 
TooKoolKrisCommented:
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
 
jennifereAuthor Commented:
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now