capital letters

crazymarvin

Member
Joined
Nov 22, 2006
Messages
18
Location
Belfast, UK
Programming Experience
Beginner
Is there a way of makeing all the letters in a text box capital letters? And also is there away makeing the first letter of each word a capital? e.g if the user enters mr smith, it would automatically make that Mr Smith.

Any Ideas or suggestions?

thanks
 
Is there a way of makeing all the letters in a text box capital letters?
Yes, use .ToUpper. (ie: TextBox1.Text = TextBox1.Text.ToUpper())

nd also is there away makeing the first letter of each word a capital? e.g if the user enters mr smith, it would automatically make that Mr Smith.
I'm not sure if there is a built in function to do this in .NET as I couldn't see one. I'm sure someone will correct me if I'm wrong. But this is what I did.
VB.NET:
        Dim Words() As String = Split(TextBox1.Text, " ")
        TextBox1.Text = ""
        For Each Word As String In Words
            Word = Word.Substring(0, 1).ToUpper & Word.Substring(1)
            TextBox1.Text &= Word & " "
        Next
        TextBox1.Text.Trim()
I hope that helps.

Edit: I found a StrConv function that does the same thing.
VB.NET:
TextBox1.Text = StrConv(TextBox1.Text, VbStrConv.ProperCase)
 
Last edited:
Back
Top