Is there another way to handle the leave event of multiple textboxes other then coding in each event handler? I may not be using correct terms
instead of doing this:
exisitng Code:
Private Sub leveladjstvaltxt_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles leveladjstvaltxt.Leave
If Me.leveladjstvaltxt.Text <> "" Then
Dim levels As Integer = CInt(Me.leveladjstvaltxt.Text)
Me.leveladjstvaltxt.Text = Format(levels, "#,###")
I have 30 TextBoxes all need same formatting , so I was trying to come up with something like this:
trying Code:
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is TextBox And ctrl.Text <> "" Then
Dim val As Double = CDbl(ctrl.Text)
CType(ctrl, TextBox).Text = Format(val, "#,###")
End If
I am stuck though and dont know where i would place that code if this is something that is even possible. Only thing I can currently think of is in the leave event which defeats the purpose, I wanted to avoid having to place the code in 30 differrent textoxes leave event
Thanks for any input