troubleshooting Question

Exporting to a text file

Avatar of mgmhicks
mgmhicks asked on
Visual Basic Classic
3 Comments1 Solution213 ViewsLast Modified:
I am exporting records to a text file.  I need it seperated by comma's and I need all fields in quotes.  I can get the comma's but it doest write it with quotes.  Below is the code I am using.  Please help to get the quotes around the data.  I need in a hurry so I am offering 500pts.


Public Function WriteDetailFile(mGLAcct As String, mGLAmt As String, mPropertyID As String, mgldate As String, FileName As String)

    Dim filenumber As Integer
  '  Dim FileName As String
    Dim mRecordLine As String
    Dim mDetailLine As String
    Dim F1 As String
    Dim F3 As String
    F1 = "The Apartment Gallery "
    F2 = "Febuary 2006 Transaction Summary"
    On Error GoTo Problem
    mRecordLine = F1 & "," & mgldate & "," & F2 & "," & mGLAcct & "," & mGLAmt
    'mDetailLine = "Descrip1" & "," & "Date" & "," & "descrip2" & "," & "GLAcct" & "," & "GLAmt"
    'FileName = "F:\APPS\GPSTRANSFERS\GPS" & mCompany & mPeriod & "D.TXT"
    filenumber = FreeFile
    If (FileExists(FileName)) Then   'Append
      Open FileName For Append As #filenumber
      Print #filenumber, mRecordLine
      Close #filenumber
    Else   'Write to file
      filenumber = FreeFile
      Open FileName For Output As #filenumber
     ' Print #filenumber, mDetailLine
      Print #filenumber, mRecordLine
      Close #filenumber
    End If
    Exit Function

    MsgBox "Problem writing Detail File" & vbCrLf & Err.Description

End Function

Private Function ConvertNumber(m As Integer) As String
    If Len(Trim(m)) = 1 Then
        ConvertNumber = "0" + (LTrim(m))
        ConvertNumber = m
    End If

End Function

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros