JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
I'm writing contents of an array to a .CSV file. When I open the .CSV file, the contents are mostly symbolic characters rather than alphabetic. I can't work out what is causing this, my guess is I'm not writing the contents to the file correctly.
The array is 46 rows by 13 columns and contains a mix of strings and doubles.
The code I'm using to write the array to a .CSV file is:
Can anyone suggest why the output is not being written as expected?
TIA,
JackDanIce
I'm writing contents of an array to a .CSV file. When I open the .CSV file, the contents are mostly symbolic characters rather than alphabetic. I can't work out what is causing this, my guess is I'm not writing the contents to the file correctly.
The array is 46 rows by 13 columns and contains a mix of strings and doubles.
The code I'm using to write the array to a .CSV file is:
Code:
Private Sub Save_Results(ByRef varArrData() As Variant)
Dim strSavePath As String
Dim strFileName As String
Dim x As Long
Dim y As Long
Dim lngFileNum As Long
Const strDelim As String = ","
lngFileNum = FreeFile
strSavePath = "C:\test\"
strSavePath = strSavePath & varArrData(2, UBound(varArrData, 2))
Open strSavePath For Binary As lngFileNum
For x = LBound(varArrData, 1) To UBound(varArrData, 1)
For y = LBound(varArrData, 2) To UBound(varArrData, 2)
Put lngFileNum, , varArrData(x, y)
If y < UBound(varArrData, 2) Then Put lngFileNum, , strDelim
Next y
If x < UBound(varArrData, 1) Then Put lngFileNum, , vbCrLf
Next x
Close lngFileNum
End Sub
TIA,
JackDanIce