[Resolved]Object Instance Error
VB Code:
'from the AlphaNumericButton usercontrol
Public Function getChr() As String
If IsAlphabetic = False Then
getChr = strDigitValue
Else
If keyPadTimer.Enabled = True Then
'supposed to be working with this bit
Dim tmpArray() As String
Dim i As Integer
For i = 0 To Len(strAlphaValue)
tmpArray(i) = strAlphaValue.Substring(i, 1)
Next
For i = 0 To tmpArray.Length
MsgBox(tmpArray(i))
Next
getChr = ""
'end this bit
Else
If strAlphaValue.Length > 0 Then
getChr = strAlphaValue.Substring(0, 1)
Else
getChr = " "
End If
End If
End If
End Function
Private Sub btnKey2to9Handler(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKey2.Click, btnKey3.Click
If armed = True Or expectingInput = True Then
Static KeyValue As String
MsgBox(sender.name)
If Not lastKeyPressed Is sender Then
AlphaNumericButton.keyPadTimer.Enabled = False
End If
lastKeyPressed = sender
If AlphaNumericButton.IsAlphabetic = False Then
KeyValue = sender.Getchr
Else
'Working with this part
If Not AlphaNumericButton.keyPadTimer.Enabled Then
KeyValue = sender.Getchr
AlphaNumericButton.keyPadTimer.Enabled = True
Else
'Delete the last alpha character.
If inputBuffer.Length > 0 Then
inputBuffer = inputBuffer.Substring(0, inputBuffer.Length - 1)
End If
'Determine the next alpha character.
'Errors here if I click within one second
MsgBox(sender.Getchr)
End If
End If
End If
End Sub
Howdy folks.
My little usercontrol has a problem (), it completely crashes when I try to use sender.GetChr.(the Getchr function will recieve and return values when its finished) Basically I have a sub which handles the click events for 10 AlphaNumericButton controls (top code is from that), and they have to retrieve a value using the Getchr function. Theres a timer which is shared across all of the usercontrols called keypadtimer (which is inside the control) which is set for 1 second. So the first time I click, the timer not enabled part fires and works properly. If I wait longer than 1 second, it'll work fine again... but if I click before 1 second has elapsed, I get the following error on the Msgbox part,
Quote:
An unhandled exception of type 'System.NullReferenceException' occurred in microsoft.visualbasic.dll
Additional information: Object reference not set to an instance of an object.
Anyone?