VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Capitalize the first letter of each word in a string

by Thejan J Rajapakshe (7 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 3rd January 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Capitalize the first letter of each word in a string

API Declarations


[email protected]

Rate Capitalize the first letter of each word in a string



  t$ = Text1.Text  'the string
  If t$ <> "" Then
   Mid$(t$, 1, 1) = UCase$(Mid$(t$, 1, 1))
   For i = 1 To Len(t$) - 1
     If Mid$(t$, i, 2) = cr$ Then Mid$(t$, i + 2, 1) = UCase$(Mid$(t$, i + 2, 1))
     If Mid$(t$, i, 1) = " " Then Mid$(t$, i + 1, 1) = UCase$(Mid$(t$, i + 1, 1))
   Next
   Text1.Text = t$
  End If

Download this snippet    Add to My Saved Code

Capitalize the first letter of each word in a string Comments

No comments have been posted about Capitalize the first letter of each word in a string. Why not be the first to post a comment about Capitalize the first letter of each word in a string.

Post your comment

Subject:
Message:
0/1000 characters