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
Set
mc = match(value,
"[^0-9^,^\-^\:]+"
)
If
mc.Count > 0
Then
strOut =
""
Else
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
End
If
Encrypt = strOut
End
Function