G
Guest
Hello,
I have a group of textboxes where I change the text to lower on leave, but I
am sure there is a more efficient way to do this.
rivate Sub txt1_Leave(...) Handles txt1.Leave
Dim str1 As String = txt1.Text.ToLower
txt1.Text = str1
End Sub
Private Sub txt2_Leave(...) Handles txt2.Leave
Dim str1 As String = txt2.Text.ToLower
txt2.Text = str1
End Sub
Private Sub txtI3_Leave(...) Handles txtIDfld.Leave
Dim str1 As String = txtIDfld.Text.ToLower
txtIDfld.Text = str1
End Sub
Private Sub txt4_Leave(...) Handles txt4.Leave
Dim str1 As String = txt4.Text.ToLower
txt4.Text = str1
End Sub
I think the above can be replaced with something like
Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs)
handles txt1.leave, txt2.leave, txt3.leave, txt4.leave
Dim str1 As String = sender.ToString.ToLower
sender = str1
End Sub
this line seems to work - str1 appears to get the value from sender
Dim str1 As String = sender.ToString.ToLower
But when I try to reapply the new value to sender as below
sender = str1
nothing happends. The text in the textbox did not get changed. Any
suggestions appreciated what I could do to make this work.
Thanks,
Rich
I have a group of textboxes where I change the text to lower on leave, but I
am sure there is a more efficient way to do this.
rivate Sub txt1_Leave(...) Handles txt1.Leave
Dim str1 As String = txt1.Text.ToLower
txt1.Text = str1
End Sub
Private Sub txt2_Leave(...) Handles txt2.Leave
Dim str1 As String = txt2.Text.ToLower
txt2.Text = str1
End Sub
Private Sub txtI3_Leave(...) Handles txtIDfld.Leave
Dim str1 As String = txtIDfld.Text.ToLower
txtIDfld.Text = str1
End Sub
Private Sub txt4_Leave(...) Handles txt4.Leave
Dim str1 As String = txt4.Text.ToLower
txt4.Text = str1
End Sub
I think the above can be replaced with something like
Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs)
handles txt1.leave, txt2.leave, txt3.leave, txt4.leave
Dim str1 As String = sender.ToString.ToLower
sender = str1
End Sub
this line seems to work - str1 appears to get the value from sender
Dim str1 As String = sender.ToString.ToLower
But when I try to reapply the new value to sender as below
sender = str1
nothing happends. The text in the textbox did not get changed. Any
suggestions appreciated what I could do to make this work.
Thanks,
Rich