我需要遍历某个目录中的所有数据库,其中数据库名为ACPwxyz.mdb,其中wxyz等同于该数据库使用期间的MMYY值。
例如,2017年7月的数据库为ACP0717.mdb。
我以前从来没有用VB6写过,我非常讨厌它,但它是一个现有项目的扩展,所以我坚持使用它!
有没有一种方法可以遍历目录中的所有文件,检查文件名是否符合ACPwxyz.mdb的格式,如果符合,则打开到该文件的连接?
我看了一下Dir(x, y),但我不确定在这种情况下是否可以使用它?
任何建议都将不胜感激。
发布于 2017-07-20 16:18:59
你可以使用Dir,是的。
如果你使用类似这样的东西:
Dim strFile As String
strFile = Dir(yourDBPath, "ACP????.mdb") ' mdb for MS-Access files
Do Until strFile = ""
If Len(strFile) = 11 Then ' Ensure the DB file name is 11 characters, which yours are
'Do something // You can also check the file name doesn't = a certain name if needed
End If
strFile = Dir
LoopDir接受星号(*)或问号(?)作为文件名中的通配符,因此这将在名为ACP且后跟4个字符的集合路径中查找任何数据库。
https://stackoverflow.com/questions/45195491
复制相似问题