[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

names in capitals

i nedd the first letter of every word to be a cap


col_jack_oneal
0
pastiesrus
Asked:
pastiesrus
  • 2
1 Solution
 
Arthur_WoodCommented:
use the StrConv fuinction with the Parameter vbProperCase:

Dim strName as String
strName = "THE FULL NAME"
strName = strConv(strName,vbProperCase)

strName = "The Full Name"

AW
0
 
joyful88Commented:
dim strWord, strLeft, strRight as String

strWord = txtWord.Text
strLeft = UCase$(Left$(strWord,1))
strRight=Mid$(strWord,2,len(strWord)-1)

strWord = strLeft & strRight

-->> you may need to play around with the starting point of the Mid$ function.

0
 
Arthur_WoodCommented:
joyful88:

this line:

dim strWord, strLeft, strRight as String

does NOT do what you think it does.  It does NOT dim all three variables as string, only the strRight is Dimmed as String, the other two are VARIANTS.

and your code does not answer the question :

" nedd the first letter of EVERY word to be a cap" (my emphasis)

AW
0
 
LycaonCommented:
If you want col_jack_oneal to come out like Col_Jack_Oneal then this function would work:

Private Function Capitalize(sStr As String) As String
Dim TmpStr() As String, x As Integer

TmpStr = Split(sStr, "_")

For x = LBound(TmpStr) To UBound(TmpStr)
Capitalize = Capitalize & StrConv (TmpStr(x), vbProperCase) & "_" ' Replace _ with any other character you want.  Use a space to turn col_jack_oneal into Col Jack Oneal

End Function
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now