请高手们帮我看看这段代码 也帮我加一下注释:
Public Path As StringPrivate Sub cmdOpen_Click()
Dim strFileName As String
Dim i As Integer, j As Integer
frmOpen.Show 1 '调用frmopen窗体
If Path = "" Then Exit Sub
lblStatus2.Caption = "当前文件夹:" & Path
Path = Path & "\"
lstPicName.Clear '清空列表框
'i=1 to 6
For i = 1 To FileType
intFileTypeNum(i) = 0
strFileName = Dir(Path & "*." & strFileType(i))
Do While Not strFileName = ""
intFileTypeNum(i) = intFileTypeNum(i) + 1
lstPicName.AddItem strFileName '向列表框中添加文件名
strFileName = Dir()
Loop
Next
If lstPicName.ListCount > 0 Then
lstPicName.ListIndex = 0
picShow.Picture = LoadPicture(Path & lstPicName.Text)
opened = True
Else
picShow.Picture = LoadPicture
opened = False
End If
lblStatus1.Caption = "共 " & lstPicName.ListCount & " 张,第 " & lstPicName.ListIndex + 1 & " 张"
If lstPicName.ListCount <> 0 Then
cmdNavi(2).Enabled = True
cmdNavi(3).Enabled = True
cmdSlide.Enabled = True
End If
End Sub
Private Sub Form_Load()
strFileType(1) = "BMP"
strFileType(2) = "JPG"
strFileType(3) = "GIF"
strFileType(4) = "WMF"
strFileType(5) = "CUR"
strFileType(6) = "ICO"
End Sub
这是frmOpen 窗体中的代码
Option ExplicitPrivate Sub cmdCancel_Click()
frmMain.Path = ""
Unload Me
End SubPrivate Sub cmdOK_Click()
'frm窗体的path变量等于 dir 列表中 当前的所有内容
'List设置控件的列表部分的项目 ListIndex控件中当前选择项目
frmMain.Path = Dir1.List(Dir1.ListIndex)
Unload Me
End SubPrivate Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End SubPrivate Sub Form_Load()
frmMain.Path = "" '清空 Path 变量
End Sub
特别是这段:
For i = 1 To FileType
intFileTypeNum(i) = 0
strFileName = Dir(Path & "*." & strFileType(i))
Do While Not strFileName = ""
intFileTypeNum(i) = intFileTypeNum(i) + 1
lstPicName.AddItem strFileName
strFileName = Dir()
Loop
Next
Public Path As StringPrivate Sub cmdOpen_Click()
Dim strFileName As String
Dim i As Integer, j As Integer
frmOpen.Show 1 '调用frmopen窗体
If Path = "" Then Exit Sub
lblStatus2.Caption = "当前文件夹:" & Path
Path = Path & "\"
lstPicName.Clear '清空列表框
'i=1 to 6
For i = 1 To FileType
intFileTypeNum(i) = 0
strFileName = Dir(Path & "*." & strFileType(i))
Do While Not strFileName = ""
intFileTypeNum(i) = intFileTypeNum(i) + 1
lstPicName.AddItem strFileName '向列表框中添加文件名
strFileName = Dir()
Loop
Next
If lstPicName.ListCount > 0 Then
lstPicName.ListIndex = 0
picShow.Picture = LoadPicture(Path & lstPicName.Text)
opened = True
Else
picShow.Picture = LoadPicture
opened = False
End If
lblStatus1.Caption = "共 " & lstPicName.ListCount & " 张,第 " & lstPicName.ListIndex + 1 & " 张"
If lstPicName.ListCount <> 0 Then
cmdNavi(2).Enabled = True
cmdNavi(3).Enabled = True
cmdSlide.Enabled = True
End If
End Sub
Private Sub Form_Load()
strFileType(1) = "BMP"
strFileType(2) = "JPG"
strFileType(3) = "GIF"
strFileType(4) = "WMF"
strFileType(5) = "CUR"
strFileType(6) = "ICO"
End Sub
这是frmOpen 窗体中的代码
Option ExplicitPrivate Sub cmdCancel_Click()
frmMain.Path = ""
Unload Me
End SubPrivate Sub cmdOK_Click()
'frm窗体的path变量等于 dir 列表中 当前的所有内容
'List设置控件的列表部分的项目 ListIndex控件中当前选择项目
frmMain.Path = Dir1.List(Dir1.ListIndex)
Unload Me
End SubPrivate Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End SubPrivate Sub Form_Load()
frmMain.Path = "" '清空 Path 变量
End Sub
特别是这段:
For i = 1 To FileType
intFileTypeNum(i) = 0
strFileName = Dir(Path & "*." & strFileType(i))
Do While Not strFileName = ""
intFileTypeNum(i) = intFileTypeNum(i) + 1
lstPicName.AddItem strFileName
strFileName = Dir()
Loop
Next
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货