📄 mod_publicfunction.bas
字号:
Attribute VB_Name = "Mod_PublicFunction"
'判断文件或目录是否存在
Public Function Exists(ByVal Str_FileName As String, _
ByVal Int_Val As VbFileAttribute) As Boolean
On Error Resume Next
If Int_Val <> vbDirectory Then '如果不是目录
'如果为空表示文件不存在
If Dir(Str_FileName) = "" Then
Exists = False
Else
Exists = True
End If
Else
If Dir(Str_FileName, vbDirectory) = "" Then
Exists = False
Else
Exists = True
End If
End If
End Function
'取指定范围内的字符
'参数说明:
'String1 为源字符串,即分解前的字符串
'KeyStatr 是指开始字符串
'KeyEnd 是指结束字符串
Public Function Fun_GetStr(ByVal String1 As String, _
ByVal KeyStatr As String, _
ByVal KeyEnd As String, _
Optional ByVal Statr As Integer = 1) As String
Dim lng_Statr As Long
Dim lng_End As Long
'求出出现开始字符串和结束字符串的位置
lng_Statr = InStr(Statr, String1, KeyStatr) + Len(KeyStatr)
lng_End = InStr(lng_Statr, String1, KeyEnd)
If lng_Statr = 0 Or lng_End = 0 Then
Fun_GetStr = ""
Exit Function
End If
Fun_GetStr = Mid$(String1, lng_Statr, lng_End - lng_Statr)
End Function
'取不重复的文件名
Public Function GetNotRepeatFileName(ByVal Str_FileName As String) As String
Dim i As Integer
Dim Str_Prefix As String '文件前缀
Dim Str_Postfix As String '文件后缀,带"."
Str_Prefix = Left$(Str_FileName, InStrRev(Str_FileName, ".") - 1)
Str_Postfix = Mid$(Str_FileName, InStrRev(Str_FileName, "."))
i = 0
Do While Dir(Str_FileName, vbNormal) <> ""
Str_FileName = Str_Prefix & i & Str_Postfix
i = i + 1
Loop
GetNotRepeatFileName = Str_FileName
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -