I am working on a VB6 project and I am trying to export fields from a listbox into a csv file. I can get the titles to export but none of the actual content from the listbox is being exported to the newly created csv file. Is there something missing in my code that can is suppose to be there to export the content.
Code:
Private Sub btnExport_Click()
'This subroutine exports the list to a CSV file
Dim OpenFile As Integer
Dim Count As Integer
Dim Element As Integer
Dim FilePath As String
Dim SamplePlant() As String
Dim SampleBatch() As String
Dim SampleStage() As String
Dim SampleTime() As String
Dim SampleAcidNumber() As String
Dim SampleViscosity() As String
Dim SampleTemp() As String
Dim SampleFlow() As String
Dim SampleANDiff() As String
Dim SamplePredAdd() As String
Dim SamplePredAmt() As String
Dim SampleActAdd() As String
Dim SampleActAmt() As String
FilePath = App.Path & "\Exported\"
glbExportPath = FilePath
'Write to file
OpenFile = FreeFile
Open glbExportPath & "Recommended Addition(" & lblProduct(16).Caption & ").csv" For Output As OpenFile
'Header
Print #OpenFile, "Plant, Batch, Stage, Time, Acid Number, Viscosity, Temp, Flow, Acid Number Difference, Predicted Add, Predicted Amount, Actual Add, Actual Amount"
'Body
For Count = 1 To Element
Print #OpenFile, SamplePlant(Count) & ", " & SampleBatch(Count) & ", " & SampleStage(Count) & ", " & SampleTime(Count) & ", " & SampleAcidNumber(Count) & ", " & SampleViscosity(Count) & ", " & SampleTemp(Count) & ", " & SampleFlow(Count) & ", " & SampleANDiff(Count) & ", " & SamplePredAdd(Count) & ", " & SamplePredAmt(Count) & ", " & SampleActAdd(Count) & ", " & SampleActAmt(Count); ""
Next Count
Count = Count + 1
Close OpenFile
MsgBox "The data has been exported. The following file was created: " & glbExportPath & "Recommended Addition ( " & lblProduct(16).Caption & ").csv", vbExclamation, "File Done"
End Sub