请用VB.NET写一段模糊查找的程序,并在注释中解释每一行的意思
时间: 2023-02-25 14:29:21 浏览: 141
Option Explicit'定义模糊查找的变量
Dim FuzzySearchString As String'获取模糊查找的字符串
FuzzySearchString = InputBox("请输入要搜索的模糊字符串:")'定义要搜索的文件夹路径
Dim FilePath As String'获取要搜索的文件夹路径
FilePath = InputBox("请输入要搜索的文件夹路径:")'定义文件系统对象
Dim FSO As Scripting.FileSystemObject'创建文件系统对象
Set FSO = New Scripting.FileSystemObject'定义文件夹对象
Dim Folder As Scripting.Folder'获取文件夹对象
Set Folder = FSO.GetFolder(FilePath)'定义文件对象
Dim File As Scripting.File'定义文件名字符串
Dim FileName As String'使用For Each循环遍历文件夹对象
For Each File In Folder.Files
'获取文件名
FileName = File.Name
'判断文件名是否包含模糊字符串
If InStr(1, FileName, FuzzySearchString, vbTextCompare) > 0 Then
'如果包含,输出文件名
MsgBox FileName
End If
Next
相关问题
请用VB.NET写一段模糊查找的程序,并在注释中解释
VB.NET程序:Dim strSearch As String = "模糊查找"'使用模糊查找,可以查找包含指定字符的所有字符串
'例如,strSearch可以被用来查找包括“模糊查找”的字符串
Dim results As String() = strSearch.Split(" "c)
For Each result As String In results
Console.WriteLine(result)
Next
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)