search this site the web
Showing posts with label textbox. Show all posts
Showing posts with label textbox. Show all posts

Tuesday, March 16, 2010

Upper Case Letters in Text Box in vb.net

Private Sub ValidateNameTextBox(ByRef TB As TextBox)

If Not TB.Text = String.Empty Then
TB.Text = TB.Text.Substring(0, 1).ToUpper() & TB.Text.Substring(1, TB.Text.Length - 1).ToUpper()
TB.SelectionStart = TB.Text.Length
End If
End Sub


Private Sub Textbox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Textbox1.TextChanged
ValidateNameTextBox(Me.Textbox1)
End Sub

VB6 code for Clearing all Textbox in a Form

'Add 1 CommandButton and few TextBoxes To Your Form.
'Insert the following code to your form:

Private Sub Command1_Click()
Dim Contrl As Control
For Each Contrl In Form1.Controls
If (TypeOf Contrl Is TextBox) Then Contrl.Text = ""
Next Contrl
End Sub