It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Learning VB6: Output to a text file!

Moderator: dafunkymunky

Learning VB6: Output to a text file!

Postby MattFaY2k on Sat Oct 09, 2004 9:59 am

Hi all,

I would like to know how i can output the value of a variable to a text file?

any help would be appreciated :)

Matt
MattFaY2k
 
Posts: 0
Joined: Sat Oct 09, 2004 9:51 am

Postby Malcolm on Sat Oct 09, 2004 12:38 pm

User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

see how it will work

Postby techyashish on Sat Oct 09, 2004 6:30 pm

Dim Fso as new FileSystemObject
Dim FileToread As TextStream
Dim CurrentLine as String

dim var1
dim var2

var1 = "Adfasdf"
var2 = "asdfasdfsadfasdf"

Set FileToread = fso.OpenTextFile("C:\a.txt", ForReading)

Do Whiile FileToread.AtEndOfStream = False
CurrentLine=FileToread.ReadLine
msgbox CurrentLine
Loop

*******************************************

Writing to text file
***********************
Dim FileToWrite as TextStream

Set FileToWrite = Fso.OpenTextFile("C:\mytxtfile", ForWriting, True)

FileToWrite.WriteLine var1
FileToWrite.WriteLine var2
FileToWrite.Close
techyashish
 
Posts: 10
Joined: Wed Oct 06, 2004 6:27 pm
Location: toronto

Postby dragul on Wed Apr 20, 2005 8:20 pm

You dont need all that stuff, outputing data to .txt file is much simpler than that:

open "c:\mytextfile.txt" for output as #1
write#1, variablename
close#1

its that simple
dragul
 
Posts: 16
Joined: Wed Apr 20, 2005 7:54 pm
Location: Abergavenny, Wales, UK

Postby amino0o on Fri Jun 29, 2007 9:49 am

dragul wrote:You dont need all that stuff, outputing data to .txt file is much simpler than that:

open "c:\mytextfile.txt" for output as #1
write#1, variablename
close#1

its that simple


thats vb6

and make sure there are spaces between write and close and #1


and dont use write , cuz when u do , ur values are written into a txt file with quotes ...use print
amino0o
 
Posts: 6
Joined: Thu Jun 28, 2007 11:11 pm


Who is online

Users browsing this forum: No registered users and 2 guests