I working on a project that includes to call a certain type of method to each control, i have this code:
This code works like a charm if i want to allow only numbers and backspace on my textbox.Code:Private Sub txtBcNum1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBcNum1.KeyPress If Char.IsDigit(e.KeyChar) Or e.KeyChar = Chr(8) Then e.Handled = False Else e.Handled = True End If End Sub
Problem: I have 15 textboxes( txtBcNum1,txtBcNum2,....,txtBcNum15 ), what's the best way to call this function inside KeyPress method on each textboxes with out manually adding it to KeyPress method?




Reply With Quote
