How to capitalized textbox entry?

cwyong1

Active member
Joined
May 20, 2007
Messages
35
Programming Experience
Beginner
How do i capitalised textbox entry as it is being entered?

TQVM
 
Well that certainly is harder than I first thought.

Here's the best I can do.
Also note that the blnNoEvents is a global variable that keeps this
sub from being recursive

VB.NET:
Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged
        'upper case text
        If blnNoEvents = True Then Exit Sub
       
        blnNoEvents = True

        txtName.Text = UCase(txtName.Text)
        Dim ThisControl As New System.Windows.Forms.TextBox
        Dim NetSelLength_int As Integer
        Dim MyActiveForm As Form = System.Windows.Forms.Form.ActiveForm
        ThisControl = MyActiveForm.ActiveControl
        ThisControl.Text = MyActiveForm.ActiveControl.Text
        NetSelLength_int = Len(txtName.Text) 'ThisControl.SelectionLength
        ThisControl.SelectionStart = NetSelLength_int
        blnNoEvents = False

    End Sub
There could be a much easier way to do this but I felt obligated after
my first post made it sound easy. As it turns out I can use this also

... good luck
 
I would like to share this tip with u people.

I managed to figure out a way to capitalized character by character as they are being entered into the textbox and here is the code

sub TxtUserIDTextChanged(ByVal sender As Object, ByVal e As EventArgs)
m_TxtUserID.Text = ucase(m_TxtUserID.Text)
m_TxtUserID.SelectionStart = len(m_TxtUserID.Text)
End Sub

Hope it is of use to you peoples

BYE BYE
 
Just set property CharacterCasing to Upper for the Textbox.
 
Back
Top