Export a Grid to a text file
Export a Grid to a text file
Rate Export a Grid to a text file
(1(1 Vote))
' * Programmer Name : Waty Thierry
' * Web Site : www.geocities.com/ResearchTriangle/6311/
' * E-Mail : [email protected]
' * Date : 13/10/98
' * Time : 09:18
' * Module Name : Grid_Module
' * Module Filename : Grid.bas
' **********************************************************************
' * Comments : Export a grid to a text file
' **********************************************************************
Public Sub GridExport(GridToExport _
As Object, FileName As String, Optional _
Delimiter As Variant, Optional _
EncloseStrings As Variant)
Dim iNumRows As Integer
Dim iNumCols As Integer
Dim iFileNumber As Integer
If IsMissing(Delimiter) Then
Delimiter = vbTab
End If
If IsMissing(EncloseStrings) Then
EncloseStirngs = ""
End If
iFileNumber = FreeFile
Open FileName For Output As #iFileNumber
For iNumRows = 0 To _
GridToExport.rows - 1
GridToExport.Row = iNumRows
For iNumCols = 0 To _
GridToExport.Cols - 1
GridToExport.col = iNumCols
'if it isn't the first column,
'put a delimiter before the value
If iNumCols > 0 Then
Print #iFileNumber, Delimiter;
End If
Print #iFileNumber, EncloseStrings & _
GridToExport.Text & EncloseStrings;
Next iNumCols
Print #iFileNumber, ""
Next iNumRows
Close #iFileNmuber
End Sub
Private Sub cmdExport_Click()
Call GridExport(MSFlexGrid1, "c:/test.csv", ",", Chr$(34))
End Sub
Private Sub Form_Load()
MSFlexGrid1.AddItem "Sam Huggill"
MSFlexGrid1.AddItem "VB Square"
End Sub
Export a Grid to a text file Comments
No comments yet — be the first to post one!
Post a Comment