proper case code attached

Results 1 to 3 of 3

Thread: proper case code attached

  1. #1
    the other steve Guest

    Default proper case code attached

    Someone named Mark Fulford posted a little function to convert words to "propercase".<BR><BR>I know you can do this much simpler with regular expressions, but in the interest of sharing my own bad code with the crowd, here&#039;s mark&#039;s code again, as modified by me. The new code includes the case of "macdonald" as well as "mcdonald". Also it only works on "mc" and "mac" at the beginning of the name so it doesn&#039;t turn "samclan" into "SamcLan". But it won&#039;t work on "frank mccourt" - it no longer looks past the beginning for "mac" and "mc" since my forms ask for last name and first name separately.<BR><BR>dim i <BR>dim strOut, strChar, strTwoChars <BR>dim bCapitalize <BR><BR>Function propercase(strIn) <BR>bCapitalize = true <BR><BR>for i = 1 to len(strIn) <BR> strChar = mid(strIn, i, 1) <BR> if bCapitalize = true then <BR> strOut = strOut + UCase(strChar) <BR> else <BR> strOut = strOut + lcase(strChar) <BR> end if <BR> bCapitalize = false <BR> select case strChar <BR> case " ", "&#039;" <BR> bCapitalize = true <BR> end select <BR> if i = 2 then<BR> strTwoChars = mid(strIn, i-1, 2)<BR> select case ucase(strTwoChars) <BR> case "MC"<BR> bCapitalize = true <BR> end select<BR> end if<BR> if i = 3 then<BR> strTwoChars = mid(strIn, i-2, 3)<BR> select case ucase(strTwoChars) <BR> case "MAC" <BR> bCapitalize = true <BR> end select<BR> end if <BR>next<BR><BR>propercase = strOut <BR>End Function

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Are you just sharing code

    or is there a question i missed?<BR><BR>

  3. #3
    the other steve Guest

    Default yea, response to an old post...

    from a few days ago...didn&#039;t mean to confuse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts