Function
Encrypt(value
As
String
)
As
String
Dim
vval()
As
String
Dim
strOut
As
String
Dim
iVal
As
Integer
Dim
iCnt
As
Integer
, iStart
As
Integer
, iEnd
As
Integer
, iStep
As
Integer
Dim
mc
As
VBScript_RegExp_55.MatchCollection
vval = Split(value,
","
)
For
iVal = 0
To
UBound(vval)
If
InStr(vval(iVal),
"-"
) > 0
Then
iStep = 1
Set
mc = match(vval(iVal),
":([0-9]+)"
)
If
Not
mc
Is
Nothing
Then
iStep = mc.Item(0).SubMatches(0)
End
If
Set
mc = match(vval(iVal),
"([0-9]+)-([0-9]+)"
)
If
Not
mc
Is
Nothing
Then
iStart = mc.Item(0).SubMatches(0)
iEnd = mc.Item(0).SubMatches(1)
End
If
For
iCnt = iStart
To
iEnd
Step
iStep
strOut = strOut & IIf(strOut =
""
,
""
,
";"
) &
CStr
(iCnt)
Next
Else
strOut = strOut & IIf(strOut =
""
,
""
,
";"
) & vval(iVal)
End
If
Next
Encrypt = strOut
End
Function
Function
match(value
As
String
, strPattern
As
String
)
As
VBScript_RegExp_55.MatchCollection
Dim
regEx
As
New
VBScript_RegExp_55.RegExp
regEx.Global =
True
regEx.pattern = strPattern
regEx.IgnoreCase =
True
If
regEx.Test(value)
Then
Set
match = regEx.Execute(value)
Else
Set
match =
Nothing
End
If
End
Function