D
Dave
I'm using several routines in my program that work on properties in a
textbox. The KeyPress is one of them. They all work fine for all of the
textboxes listed in the Handles ... part of the sub shown below. Except for
one. I have one text box, txtAdd2, that ends up being passed to the subs as
'Nothing'. So when I try to reference the object in my subroutines I get the
following error:
"An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object."
Here is the KeyPress event code. Stepping through the program the error
triggers on the Me.SelectNextControl line because the sender is 'Nothing'. I
get similar errors when sending a reference to txtAdd2 to other routines;
Private Sub Enter_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtAdd1.KeyPress,
txtAdd2.KeyPress, txtAdded.KeyPress, txtBDay.KeyPress, txtCity.KeyPress,
txtEMail.KeyPress, txtFName.KeyPress, txtHPhone.KeyPress,
txtJoined.KeyPress, txtLName.KeyPress, txtMPhone.KeyPress,
txtState.KeyPress, txtStatus.KeyPress, txtWeb.KeyPress, txtWPhone.KeyPress,
txtZip.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
Me.SelectNextControl(cType(sender, TextBox), True, True, False,
True)
End If
End Sub
Any help would be appreciated.
Thanks,
Dave
textbox. The KeyPress is one of them. They all work fine for all of the
textboxes listed in the Handles ... part of the sub shown below. Except for
one. I have one text box, txtAdd2, that ends up being passed to the subs as
'Nothing'. So when I try to reference the object in my subroutines I get the
following error:
"An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object."
Here is the KeyPress event code. Stepping through the program the error
triggers on the Me.SelectNextControl line because the sender is 'Nothing'. I
get similar errors when sending a reference to txtAdd2 to other routines;
Private Sub Enter_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtAdd1.KeyPress,
txtAdd2.KeyPress, txtAdded.KeyPress, txtBDay.KeyPress, txtCity.KeyPress,
txtEMail.KeyPress, txtFName.KeyPress, txtHPhone.KeyPress,
txtJoined.KeyPress, txtLName.KeyPress, txtMPhone.KeyPress,
txtState.KeyPress, txtStatus.KeyPress, txtWeb.KeyPress, txtWPhone.KeyPress,
txtZip.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
Me.SelectNextControl(cType(sender, TextBox), True, True, False,
True)
End If
End Sub
Any help would be appreciated.
Thanks,
Dave