-
Notifications
You must be signed in to change notification settings - Fork 6
/
modGenFnc.bas
executable file
·75 lines (59 loc) · 1.73 KB
/
modGenFnc.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Attribute VB_Name = "modGenFnc"
Option Explicit
Option Compare Binary
Option Base 0
Sub AddToLog(txtLog As TextBox, ByVal a As String, Optional bNewLine As Boolean = True)
If bNewLine = True Then
a = IIf(Len(txtLog.Text) > 0, vbNewLine, "") & Format(Now, "hh:mm:ss") & vbTab & a
End If
txtLog.SelStart = Len(txtLog.Text)
txtLog.SelText = a
txtLog.SelStart = Len(txtLog.Text)
End Sub
Function ConvertSecToMin(ByVal s As Long) As String
On Error GoTo ConvertSecToMin_err
Dim a As Long
a = (s Mod 60) 'get the seconds
ConvertSecToMin = Trim$(Str$(((s - a) / 60))) & ":" & Right$("0" & Trim$(Str$(a)), 2)
Exit Function
ConvertSecToMin_err:
ConvertSecToMin = ""
End Function
Function TrncFilePath(f As String, n As Long) As String
Dim i As Long, j As Long, x As Long
x = 1
i = -1
For j = n - 1 To 0 Step -1
i = InStrRev(f, "\", IIf(j = n - 1, -1, i - 1))
If i > 0 Then x = i Else Exit For
Next j
TrncFilePath = Mid$(f, x + 1)
End Function
Function RemExtFromPath(f As String) As String
Dim x As Long
x = InStrRev(f, ".")
If x > 0 Then
RemExtFromPath = Mid$(f, 1, x - 1)
Else
RemExtFromPath = f
End If
End Function
Function FileNameFromPath(f As String) As String
FileNameFromPath = Mid$(f, InStrRev(f, "\") + 1)
End Function
Function FileFolderFromPath(f As String) As String
FileFolderFromPath = Mid$(f, 1, InStrRev(f, "\"))
End Function
Public Function FileExt(f As String) As String
FileExt = Mid(f, InStrRev(f, ".") + 1)
End Function
Function IsCompiled() As Boolean
Dim b As Boolean
b = False
Debug.Assert IsCompiled_check(b)
IsCompiled = Not b
End Function
Private Function IsCompiled_check(b As Boolean) As Boolean
b = True
IsCompiled_check = True
End Function