-
I have i lite serial number:
1231728631652436125346152364124512653421543521374527145
I want to put a - after each caracter..
BUT I dont want that:
12345-12345-12-----
So the function must calculate the LEN an calculate how many - he must put...
so ex:
12345-12345-12345-12345-12345-23
12353-31235-1325
understand ??
I hope ;0)
-
not replace, put between to 5 - 6 char and the 10 - 11 ......
-
A perfect case for recursion...
Code:
Public Function InsertDash(pInterval As Long, pText As String) As String
Dim lstrTemp As String
If Len(pText) <= pInterval Then
InsertDash = pText
Else
lstrTemp = Left$(pText, pInterval)
InsertDash = lstrTemp & "-" & InsertDash(pInterval, Mid$(pText, pInterval + 1, Len(pText) - (pInterval)))
End If
End Function
Pass it the string and the interval (eg. 5) between dashes
- gaffa