I had a hunch there'd be  more coming.....

David Blocker
[EMAIL PROTECTED]
781-784-1919
Fax: 781-784-1860
Cell: 339-206-0261
----- Original Message ----- 
From: "MikeB" <[EMAIL PROTECTED]>
To: "RBG7-L Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, December 08, 2004 11:14 AM
Subject: [RBG7-L] - Re: Label Text Formatting


> Ok.. Now mckibben and mccomb become McKibben and McComb
> 
> 'Option explicit
> 
> 'msgbox CapitalizeValue(WScript.Arguments(0))
> 'wscript.quit()
> 
> Function CapitalizeValue(sStringIN)
>    Dim i
>    Dim s
>    Dim sNewName
>    Dim sChar
>    Dim arString
>    Dim bIsCapital
>    Dim bCapitalizeNext
> 
>    'Get rid of:
>    '  leading or trailing blanks,
>    '  Double Spaces, space comma space
>    '  Existing Caps
>    sStringIN = Replace(sStringIN,","," , ")
>    sStringIN = Trim(LCase(DropDblSpace(sStringIN)))
>    ' replace comma with space comma space to preserve comma
>    if sStringIN = "" then
>      CapitalizeValue = sStringIN
>    end if
>    bCapitalizeNext = true
>    For i = 1 to Len(sStringIN)
>          sChar = Mid(sStringIN,i,1)
>          if (bCapitalizeNext = true) then
>              if IsLetter(sChar) = true then
>                 sChar = UCase(sChar)
>                 bCapitalizeNext = False
>              else
>                 bCapitalizeNext = True
>              end if
>          else
>            if IsLetter(sChar) = false then
>                bCapitalizeNext = true
>             end if
>          end if
>         sNewName = sNewName & sChar
>    Next
>     ' Check for Roman Numerals as Last element of sNewName
>     arString = Split(sNewName," ")
>     if ubound(arString) > 0 then
>       for i = 0 to ubound(arString)
>           arString(i) = Trim(arString(i))
>           if isRoman(arString(i)) = True then
>             arString(i) = ucase(arString(i))
>           else
>             If UCase(Left(arString(i),2)) = "MC" Then
>               s = arString(i)
>               arString(I) = ( UCase(Mid(s,1,1)) & LCase(Mid(s,2,1)) &
> UCase(Mid(s,3,1)) & LCase(Mid(s,4,Len(s)-3)))
>             End if
>           end if
>       next
>       for i = 0 to ubound(arString)
>         If (arString(i) <> "") or (arString(i) <> " ") then
>           if arString(i) <> "," then
>             CapitalizeValue =  CapitalizeValue & " " & arString(i)
>           else
>             CapitalizeValue =  CapitalizeValue & arString(i)
>           end if
>         End if
>       Next
>     else
>       CapitalizeValue = sNewName
>      end if
>      CapitalizeValue = Trim(Replace(CapitalizeValue,",",", "))
> end Function
> 
> function DropDblSpace(sStr)
> Dim s
> Dim r
> s = Chr(20) & Chr(44)
> r = Chr(44)
>  while InStr(sStr,s) > 0
>    sStr = Replace(sStr,s,r)
>   wend
>  While Instr(1,sStr,"  ") > 0
>    sStr = Replace(sStr, "  ", " ")
>  wend
>    DropDblSpace = sStr
> end function
> 
> function IsLetter(sChar)
>   Dim i
>   i = CInt((Asc(sChar)))
>   IsLetter = False
>   if ((i >=65) and (i <=90)) Then
>     IsLetter = true   ' Upper case letters
>   End if
>   if ((i >=97) and (i <=122)) Then
>     IsLetter = True ' Lower case letters
>   End if
> end function
> 
> Private Function IsRoman(ByVal sStr)
>   Dim i
>   Dim s
>   IsRoman = TRUE
>   s = Trim(UCase(sStr))
>   for i = 1 to len(s)
>     if inStr(1, "MDCLXVI", mid(s,i,1)) = 0 then
>       isRoman = False
>       exit For
>     end if
>    Next
> End Function
> 

Reply via email to