Turn the first letter of each word to uppercase


Input:
1. response.write format_ucase("HELLO WORLD!")
2. response.write format_ucase("hello world!")
3. response.write format_ucase(trim(request.form("user_input")))

Output:

Hello World!


Code:

function format_ucase(tname)
  do while instr(tname, " ")
    temp_string = left(tname, instr(tname," " ) -1)
' ucase the first letter
format_ucase = format_ucase & ucase(mid(temp_string, 1,1))
' lcase for the rest of the word
format_ucase = format_ucase & lcase(mid(temp_string,2)) & " "
tname = right(tname, len(tname) - instr(tname," " ))
  loop
  'send out the rest of the word
format_ucase = format_ucase & ucase(mid(tname, 1,1))
format_ucase = format_ucase & mid(tname,2)
end function


Back to scripts