1.只把 date 日期欄位讀入陣列
2.讀取 date資料後,先轉換格式再存入陣列 (原始格式為 2016-07-27 希望能變成 2016/07/28)
請教高手如何修改 謝謝
Sub cmdGo_Click()
Dim file_name As String
Dim fnum As Integer
Dim whole_file As String
Dim lines As Variant
Dim one_line As Variant
Dim num_rows As Long
Dim num_cols As Long
Dim the_array() As String
Dim R As Long
Dim C As Long
file_name = ThisWorkbook.Path
If Right$(file_name, 1) <> "\" Then file_name = _
file_name & "\"
file_name = file_name & "test.csv"
' Load the file.
fnum = FreeFile
Open file_name For Input As fnum
whole_file = Input$(LOF(fnum), #fnum)
Close fnum
' Break the file into lines.
lines = Split(whole_file, vbCrLf)
For R = 0 To num_rows
If Len(lines(R)) > 0 Then
one_line = Split(lines(R), ",")
For C = 0 To num_cols
the_array(R, C) = one_line(C)
Next C
End If
Next R
' Prove we have the data loaded.
For R = 0 To num_rows
For C = 0 To num_cols
MsgBox the_array(R, C) & "|"
Next C
Debug.Print
Next R
Debug.Print "======="
End Sub作者: yurckr 時間: 2016-8-2 12:27