VB 怎么检索FileListBox控件里的文件名,如名称有就执行一个动作没有名称就执行另一个
展开全部
Private Sub Command1_Click()
Dim H As Boolean
H = False
For i = 0 To File1.ListCount - 1
If File1.List(i) = "1.txt" Then
H = True
Exit For
End If
Next i
If H = True Then
Shell "Notepad.exe " & File1.Path & "\" & File1.List(i), vbNormalFocus
Else
MsgBox "没有可以打开的文件"
End If
End Sub
Private Sub Form_Load()
File1.Path = "E:\编程代码"
End Sub
Dim H As Boolean
H = False
For i = 0 To File1.ListCount - 1
If File1.List(i) = "1.txt" Then
H = True
Exit For
End If
Next i
If H = True Then
Shell "Notepad.exe " & File1.Path & "\" & File1.List(i), vbNormalFocus
Else
MsgBox "没有可以打开的文件"
End If
End Sub
Private Sub Form_Load()
File1.Path = "E:\编程代码"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
Dim bln As Boolean
For i = 0 To File1.ListCount - 1
If File1.List(i) = "要搜索的文件名包括后缀名" Then
bln = True
Exit For
End If
Next
If bln = True Then
'执行搜索到的代码
Else
'未搜索到
End If
End Sub
Dim bln As Boolean
For i = 0 To File1.ListCount - 1
If File1.List(i) = "要搜索的文件名包括后缀名" Then
bln = True
Exit For
End If
Next
If bln = True Then
'执行搜索到的代码
Else
'未搜索到
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询