1.

Solve : Outputting to a txt file - VB?

Answer»

VB Express 2005

How do I create a text file and then output variables to it? I found an example but it will only create the text file and the rest won't work. I don;t know where that code went to anyway.One way would be to use a StreamWriter object:

Code: [Select]Using SW As StreamWriter = New StreamWriter("c:\temp\TestFile.txt")
sw.Writeline("This is line 1")
sw.Writeline("This is line 2")
sw.Writeline("This is line 3")
sw.Writeline("This is line 4")
sw.WriteLine(DateTime.Now)
sw.close()
End Using

For my own information, do the Express versions COME with Help?

Good LUCK.
yes. I try it but the examples don't ALWAYS work for me. actually they rarely work properly.

thank you.LOL. I don't know all the errors in VB bu it says type 'streamwriter' is not defined.Sorry for the confusion. You also need to add these two lines your declaration section:

Code: [Select]Imports System
Imports System.IO

The examples don't always work for me either.
Thank you, thank you, thank you. lol



Discussion

No Comment Found