OutPutArrtoCSV
作者:互联网
Sub OutPutArrtoCSV(ByVal CSVNm, ByVal OutPutArr, ByVal Arr_LENGTH, ByVal Arr_WIDTH)
On Error Resume Next
Dim CSVFolder As String = OutDFSPath ’ Application.StartupPath
CSVNm = Replace(CSVNm, vbCrLf, “_”)
Dim CSVFile_Str As String = CSVFolder & “” & CSVNm
Dim CSVFile
If Not System.IO.File.Exists(CSVFile_Str) Then
CSVFile = System.IO.File.Create(CSVFile_Str)
CSVFile.Close()
End If
Dim p As Integer = FreeFile()
Static index As Integer = 0
FileOpen(p, CSVFile_Str, OpenMode.Append)
WriteLine(p, "Time:", Now.ToString)
For i = 0 To Arr_LENGTH
For j = 0 To Arr_WIDTH
Write(p, OutPutArr(i, j)) ''将数组的一行写在CSV的一行
'line_str = line_str & OutPutArr(i, j) & ","
Next
WriteLine(p, "") '换行
Next
FileClose(p)
End Sub
标签:Dim,Arr,ByVal,CSVFile,OutPutArrtoCSV,Str,CSVNm 来源: https://blog.csdn.net/u012813404/article/details/122390503