投稿日 | : 2002/08/29(Thu) 11:41 |
投稿者 | : 故あって匿名 |
Eメール | : |
URL | : |
タイトル | : Re: 検索について |
こんなカンジでいいですか?
フォームにTextとList足したら動くとは思います。
------------------------------------------------------------
Option Explicit
Option Base 1
Private Const Mpath = "C:\"
Private fList() As Long
Private ItemCount As Long
Private Nowdate As Date
Private R As Long
Private msg As String
Private Sub Command1_Click()
Dim datetmp As Date
Dim fPath As String
Dim fname As String
Dim i As Long
On Error GoTo ERLABEL
Nowdate = CDate(Text1.Text)
ItemCount = 0
For i = 0 To 31 '遡る日 31日
datetmp = Nowdate - i
fPath = Mpath + Format$(datetmp, "yyyy-mm-dd") + "\"
fname = Dir$(fPath, vbDirectory)
Do While fname <> ""
If fname <> "." And fname <> ".." Then
If (GetAttr(fPath & fname) And vbDirectory) = vbNormal Then
List1.AddItem fname
ItemCount = ItemCount + 1
ReDim Preserve fList(ItemCount)
fList(ItemCount) = i
End If
End If
fname = Dir
Loop
Next i
Exit Sub
ERLABEL:
msg = "日付ちゃうねん。"
R = MsgBox(msg, vbOKOnly)
End Sub
Private Sub List1_Click()
msg = Format$((Nowdate - fList(List1.ListIndex)), "yyyy-mm-dd") + "\" + L
ist1.Text
R = MsgBox(msg, vbOKOnly, "選択したファイルのパス")
End Sub