投稿日 | : 2002/09/02(Mon) 14:52 |
投稿者 | : MANA |
URL | : |
タイトル | : 関数へのやり方 |
関数へのやり方が分かりません。このファイルを読み込む処理を関数化
したいのですが、どのようにすれば良いでしょうか?教えてください♪
Option Explicit
Option Base 1
Private Const Mpath = "C:\DATA\"
Private Nowdate As String
'***** テキストファイルを読み込む *****
Private Sub Command2_Click()
Dim strMyFile() As String
Dim strtextFile As String
Dim filekensaku As Integer
Dim kakutyosi As String
Dim i As Integer
Nowdate = Format$(Date, "yyyy-mm-dd")
kakutyosi = "TxT"
strtextFile = Dir$(Mpath & Nowdate & "\*.*")
Do While strtextFile <> ""
If StrComp(Right$(strtextFile, 3), kakutyosi, 1) = 0 Then
filekensaku = filekensaku + 1
ReDim Preserve strMyFile(filekensaku)
strMyFile(filekensaku) = strtextFile
End If
strtextFile = Dir$
Loop
For i = 1 To filekensaku
If FileLen(Mpath & Nowdate & "\" & strMyFile(i)) = 0 Then
Else
List2.AddItem strMyFile(i)
End If
Next i
End Sub
'***** テキストファイル読込み終了 *****