by phanny (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 8th June 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code is used for convert text to Upper case for the first character which is separated by space.
Private Function Convert_Text(Str As String) As String
Dim cutStr As String
Dim spLocation As Integer 'for space location
Dim strConvert As String
Str = Trim(Str)
If Str = "" Then Exit Function
If InStr(1, Str, " ") Then
spLocation = InStr(1, Str, " ")
'cutStr string from first space backward
cutStr = Trim(Mid(Str, 1, spLocation - 1))
'cut string that remains from the cutStr
Str = Trim(Mid(Str, spLocation + 1, Len(Str) - spLocation))
strConvert = UCase(Mid(cutStr, 1, 1)) + _
LCase(Mid(cutStr, 2, Len(cutStr) - 1))
'call function Convert_Text as recursive
Convert_Text = strConvert + " " + Convert_Text(Str)
Else
Convert_Text = UCase(Mid(Str, 1, 1)) + LCase(Mid(Str, 2, Len(Str) - 1))
End If
End Function
Private Sub Command1_Click()
Text1.Text = Convert_Text(Text1.Text)
End Sub
No comments have been posted about This code is used for convert text to Upper case for the first character which is separated by spac. Why not be the first to post a comment about This code is used for convert text to Upper case for the first character which is separated by spac.