Home > Visual Basic Programming > Export Data from VB6.0 to a text file

Export Data from VB6.0 to a text file



Hi,



I'm facing a problem in exporting data through VB6.0 to a text file. How can I do that? I need to get the data and use commas as separators and display in text file.



Thanks,

Dawn

    
Guest


what is the source of the data?

does it come from a database?



You can easilly use the FSO to create such a file.



could you post a bit more detail, and code you have.

Was this answer helpful ? Yes No   
Guest


here is a short example

using a recordset for data from a db


Code:



Dim FSO, theFile
set FSO = Server.CreateObject("Scripting.FileSystemObject")
set theFile = FSO.CreateTextFile("filename.txt")

while NOT rs.EOF
theFile.Write(rs("Field1") & ",")
theFile.Write(rs("Field2") & ",")
theFile.Write(rs("Field3"))
theFile.WriteLine()
rs.MoveNext
wend




hope this helps

Was this answer helpful ? Yes No   
Guest


Hi,



I'm using SQL Database. Do I need to add the reference under the library?

set FSO = Server.CreateObject("Scripting.FileSystemObject")

Was this answer helpful ? Yes No   
Guest


Hi,

sorry about that, I gave you an ASP example,

use this syntax instead


Code:



Dim fso As New FileSystemObject
set theFile = FSO.CreateTextFile("filename.txt")




hope this helps

Was this answer helpful ? Yes No   
Guest


It's Okay. Sorry to trouble you again. I can't get the FileSystemObject. Do I have to add reference?



dim fso as new FileSystemObject

Was this answer helpful ? Yes No   
Guest


yes, sorry, you need this reference



"Microsoft Scripting Runtime"




Was this answer helpful ? Yes No   
Guest


It's OKay. Thanks. I will try it out.

Was this answer helpful ? Yes No   
Guest


Thanks. It works.

Was this answer helpful ? Yes No   
Guest


no problem, glad its working

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved