Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to a text file

Status
Not open for further replies.

arrian

Programmer
Nov 11, 2003
93
CA
I'm writing fields from a database into a text file. This is working just fine. The file is used to import into a different program. The problem I'm having is that the program will not accept 2 colums(dates, in text format mmddyy) if they are enclosed in quotes(ex "091105"). Is there a way to write to the file that will NOT put quotes in that area? I can't put it in as a number, because I need the leading 0. Any ideas?
 
Here is the sub I'm currently using to write the data to the file:

Code:
Sub ExportToFile()
        Dim FileNumber As Integer
        Dim strFileName As String
        Dim strPath As String
        Dim strSQL As String
        Dim typNull As Type
        Dim strTransmit As String
        Dim dsTransmit As DataSet
        Dim rowRows As DataRow
        Dim i As Integer
        FileNumber = FreeFile()


        strFileName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\TES\transmit.csv"
        If Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\TES") = False Then
            Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\TES")
        End If
        strSQL = "Select * from TransmitTemp"
        dsTransmit = Connect(strSQL)
        FileOpen(FileNumber, strFileName, OpenMode.Output)
        For Each rowRows In dsTransmit.Tables(0).Rows
            strTransmit = ""
            For i = 0 To rowRows.ItemArray.Length() - 1
                If rowRows(i).ToString = "" Then
                    Write(FileNumber, "")
                Else
                    Write(FileNumber, rowRows(i))
                End If
            Next
            WriteLine(FileNumber)
        Next

        FileClose(FileNumber)
        SendEmail()
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top