Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capitalize first char in string after "#. " 4

Status
Not open for further replies.

sucoyant

IS-IT--Management
Sep 21, 2002
213
US
Good day all!

I'm trying to figure out how to capitalize the first character in a string after a number and period.

For example:
1. hello (Should be = 1. Hello)
...
...
10. visual (Should be = 10. Visual)

I wrote down some pseudocode, but I'm not entirely sure if I'm heading in the correct direction

[pseudocode]
If 3rd character in string = " " then
Convert 4th character to UCase
Elseif 4th character in string = " " then
Convert 5th character to UCase
End If
[/pseudocode]

Is this close to being correct?
If so, how would I actually go about converting that single character to upper case?

Thanks in advance!





________________________________________
BUDDHA.gif
Buddha. Dharma. Sangha.
 
Something like this ?
myStr="10. visual"
ipos=InStr(myStr,". ")
If ipos > 0 Then
myStr=Left(myStr,1,ipos+1) _
& UCase(Mid(myStr,ipos+2,1))_
& Mid(myStr,ipos+3)
End If
MsgBox myStr

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
In a formula, one way with data in cell A1:-

=IF(MID(A1,3,1)=" ",LEFT(A1,3)&UPPER(MID(A1,4,1))&RIGHT(A1,LEN(A1)-4),IF(MID(A1,4,1)=" ",LEFT(A1,4)&UPPER(MID(A1,5,1))&RIGHT(A1,LEN(A1)-5),A1))

Regards
Ken.............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
The following should achieve most of what you want in the most painless way:

StrConv(strMyString, vbProperCase)
 
rotflmao - That deserves a star just for pointing out how dense I was in not noticing what should have been obvious from the start :)

Obviously the formula route becomes a tad more simple with that approach:-

=PROPER(A1)

Regards
Ken..................

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
I'm sorry, I should have stated that I'm using MS Access.

I tried the Propercase, but I cant "Have The Item I'm Dealing With Look Like This".

I just need the first char in the string capped.

PHV's solution worked great. Thanks!

________________________________________
BUDDHA.gif
Buddha. Dharma. Sangha.
 
>but I cant "Have The Item I'm Dealing With Look Like This".

Ah, well the way you originally asked made it look like you only had one word after the number...

In which case, here's a variation just for fun:
Code:
Dim strSource As String
Dim strTemp() As String
strSource = "1. have the item I'm dealing with look like this"

strTemp = Split(strSource, " ")
strTemp(1) = StrConv(strTemp(1), vbProperCase)
strSource = Join(strTemp, " ")
 
And also just for the hell of it :)

=PROPER(LEFT(A1,FIND(" ",A1)+1))&RIGHT(A1,LEN(A1)-(FIND(" ",A1)+1))

Regards
Ken..............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top