表格vb代码:依次判断文件 datxt、dbtxt 是否存在
以下是使用VB代码依次判断文件"d:\a.txt"和"d:\b.txt"是否存在的示例:
Sub CheckFilesExistence()
Dim filePaths As Variant
filePaths = Array("d:\a.txt", "d:\b.txt") ' 定义文件路径数组
Dim fileExists As Boolean
For Each filePath In filePaths
fileExists = FileExists(filePath)
If fileExists Then
MsgBox filePath & " 存在"
Else
MsgBox filePath & " 不存在"
End If
Next filePath
End Sub
Function FileExists(filePath As String) As Boolean
Dim fileSystem As Object
Set fileSystem = CreateObject("Scripting.FileSystemObject")
FileExists = fileSystem.FileExists(filePath)
End Function
请确保将文件路径替换为实际要检查的文件路径。在上述示例中,我们使用FileExists函数来检查文件是否存在,并使用MsgBox来显示结果。
原文地址: https://www.cveoy.top/t/topic/jdfz 著作权归作者所有。请勿转载和采集!