Greetings!
Acutally, this is a continuation of thread705-1277401. Golom provided the code that has worked well for me except for one thing that I didn't tell him that I wanted it to do.
For example:
if a number is 1204500009 then give me 1245-09
If the tailend of this number is below 10 then add a zero to it so that it is a two digit tail. I keep goofing around with it but I can't get it to work. I don't want to mess up the existing code.
It works for these parses:
In the field,
if this number is 1204500090 then give me 1245-90
If the number is 1204500257 then give me 1245-257
If the number is 1204507890 then give me 1245-7890
If the number is 1204567890 then give me 1245-67890
Here is the code that Golom designed:
Public Function ParsedString(RawValue As String) As String
Dim NS As String
Dim EC As String
Dim C As String
Dim AddOn As Boolean
Dim n As Integer
NS = Left(RawValue,2) & Mid(RawValue,4,2) & "-"
EC = Mid(RawValue,6)
If Val(EC) <> 0 Then NS = NS & Val(EC)
If NOT IsNumeric(EC & "E0") Then
For n = 1 To Len(EC)
C = UCase(Mid(EC,n,1))
If C >= "A" AND C <= "Z" Then AddOn = True
If AddOn Then NS = NS & C
Next
End If
ParsedString = NS
End Function
Acutally, this is a continuation of thread705-1277401. Golom provided the code that has worked well for me except for one thing that I didn't tell him that I wanted it to do.
For example:
if a number is 1204500009 then give me 1245-09
If the tailend of this number is below 10 then add a zero to it so that it is a two digit tail. I keep goofing around with it but I can't get it to work. I don't want to mess up the existing code.
It works for these parses:
In the field,
if this number is 1204500090 then give me 1245-90
If the number is 1204500257 then give me 1245-257
If the number is 1204507890 then give me 1245-7890
If the number is 1204567890 then give me 1245-67890
Here is the code that Golom designed:
Public Function ParsedString(RawValue As String) As String
Dim NS As String
Dim EC As String
Dim C As String
Dim AddOn As Boolean
Dim n As Integer
NS = Left(RawValue,2) & Mid(RawValue,4,2) & "-"
EC = Mid(RawValue,6)
If Val(EC) <> 0 Then NS = NS & Val(EC)
If NOT IsNumeric(EC & "E0") Then
For n = 1 To Len(EC)
C = UCase(Mid(EC,n,1))
If C >= "A" AND C <= "Z" Then AddOn = True
If AddOn Then NS = NS & C
Next
End If
ParsedString = NS
End Function