-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdlpublic.bas
148 lines (111 loc) · 3.13 KB
/
mdlpublic.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
Attribute VB_Name = "mdlpublic"
'Licensed under the Apache License, Version 2.0 (the "License");
'you may not use this file except in compliance with the License.
'You may obtain a copy of the License at
' http://www.apache.org/licenses/LICENSE-2.0
'Unless required by applicable law or agreed to in writing, software
'distributed under the License is distributed on an "AS IS" BASIS,
'WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'See the License for the specific language governing permissions and
'limitations under the License.
Public ysize As Integer
Public ypos As Integer
Public curdir As String
'0= folder name
'1=Attribute
'2=Folder Size
Public f_attrib() As String
Public file_attrib() As String
Sub initpublic()
ysize = 0
ypos = 0
End Sub
Public Sub followmainwindow() ' this sub is to relocate windows when moved around the screen
dlglistsub.Top = Form1.Top + Form1.Height
dlglistsub.Left = Form1.Left
End Sub
'Scripting File System Object module to get Folder Size
Public Function getFolderSize(folderpath As String)
Dim fso As FileSystemObject
Set fso = New FileSystemObject
getFolderSize = fso.GetFolder(folderpath).Size
End Function
Public Function getAttribValue(attrib As Integer) As String
Dim X As Integer
Dim bit As Integer
Dim attribstring As String
'Dim currbit As Integer
Dim modulus As Integer
modulus = 0
If attrib > 0 Then
Do
For X = 0 To 5
bit = 2 ^ X
If bit = 0 Then
quotient = 1
Else
quotient = attrib \ bit
modulus = attrib Mod bit
End If
Debug.Print "Bit:" & bit & " Quotient:" & quotient & " Remainder:" & modulus
If quotient = 1 Then
If attribstring <> "" Then
attribstring = attribstring & ", "
End If
attribstring = attribstring & getAttribText(bit)
Exit For
End If
Next X
'subtract attrib in remainder
attrib = attrib - bit
Loop While modulus > 0
Debug.Print "New Attrib:" & attrib
End If
'return attrib
getAttribValue = attribstring
End Function
Private Function getAttribText(attrib As Integer) As String
Const normal = 0
Const readOnly = 1
Const hidden = 2
Const system = 4
Const directory = 16
Const archive = 32
Dim attribvalue As String
Select Case attrib
Case normal
attribvalue = "Default"
Case readOnly
attribvalue = "Read-Only"
Case hidden
attribvalue = "Hidden"
Case system
attribvalue = "System"
Case directory
attribvalue = "Directory"
Case archive
attribvalue = "Archive"
Case Else
attribvalue = "Unknown"
End Select
'return the attribvalue
getAttribText = attribvalue
End Function
Public Function extractRegex(text As String, pat As String)
Set re = New RegExp
With re
.pattern = pat
.IgnoreCase = False
.Global = True
End With
'Dim match
'For Each match In matches
'Debug.Print match.Value
'Next match
If re.Test(text) Then
Set matches = re.Execute(text)
extractRegex = matches(0)
Else
extractRegex = ""
End If
End Function