AnsweredAssumed Answered

I want to create a label expression that combines proper case with Replace

Question asked by Jed on Mar 1, 2018
Latest reply on Mar 2, 2018 by Jed

I am labeling street names and want traditional Proper (Title) case except the directional. Example, I want LILAC LANE SW to label as Lilac Lane SW instead of Lilac Lane Sw which the following code does.

 

Function FindLabel ([STREET])
  FindLabel = PCase([STREET])
End Function

Function PCase(strInput)
  Dim iPosition
  Dim iSpace
  Dim strOutput
  iPosition = 1
  Do While InStr(iPosition, strInput, " ", 1) <> 0
    iSpace = InStr(iPosition, strInput, " ", 1)
    strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
    strOutput = strOutput & LCase(Mid(strInput, iPosition + 1, iSpace - iPosition))
    iPosition = iSpace + 1
  Loop
  strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
  strOutput = strOutput & LCase(Mid(strInput, iPosition + 1))
  PCase = strOutput
End Function

 

I want to add something like this to the code above.

Function FindLabel ( [STREET] )
  FindLabel = Replace ( [STREET], " Sw"," SW")
End Function

 

I want the PCase to ignore the directionals.

thanks,

Jim

Outcomes