English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to write a program that takes a sentence as input and capitalizes the first letter of each word in the sentence as output.

2007-03-09 07:03:20 · 3 answers · asked by Ben R 1 in Computers & Internet Programming & Design

3 answers

You have to read the string by character and look for spaces, then capitalize the first character after each space.

Something like this:
strOutput = strOutput & UCASE(mid(strInput, 1, 1))
for x = 1 to len(strInput)
if mid(strInput, x, 1) = chr(32) then
x = x+1
strOutput = strOutput & chr(32) & UCASE(mid(strInput, x, 1))
else
strOutput = strOutput & mid(strInput, x, 1)
end if
next

2007-03-09 07:26:34 · answer #1 · answered by rod 6 · 0 0

because you in reality favor to transform area of teh string to uppercase the major will be to cut up the string into sections which will assist you capatilize only the component you want then "bolt" those segments again jointly. you should use the chop up function to break aside the string into sections on both aspect of the letters "cov". once that is accomplished you recognize the middle is "cov" you are able to both furnish those leters manually as "COV" or use the ToUpper function toconvert them. Then take the front, middle and end sections and reassemble them jointly Dim strF, strM, strE, strTrgt, strWord, strArray(), strRslt As String strF = "" 'the front strM = "" 'middle strE = "" 'end strRslt = "" ' result strWord = "hit upon" strTrgt = "cov" If strWord.includes(strTrgt) Then 'stumbled on "cov" - now damage aside the note utilizing the objective strArray = chop up(strWord, strTrgt) strF = strArray(0) 'includes area of note before objective strM = strTrgt.ToUpper ' use the objective to interchange the now lacking middle strE = strArray(a million) 'includes area of note after objective strRslt = strF & strM & strE ' reassemble the front middle and end into string end If 'print result obviously there are different ideas to attempt this. you should use the string position function to identity the position "cov" is then use the different purposes like mid to break aside the string into sections. or use the region recommendations from substring to identity the position the guy characters are contained in the nature array of the string then regulate each and each personality then loop through the array and reassemble a clean string. there are a range of ideas to epidermis a cat.....

2016-12-05 11:30:23 · answer #2 · answered by Anonymous · 0 0

find each period, exclamation mark or question mark and capitalize the first letter after each one.

2007-03-09 07:20:50 · answer #3 · answered by Kevin G 4 · 0 0

fedest.com, questions and answers