Results 1 to 9 of 9

Thread: [Resolved]Object Instance Error

Threaded View

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    [Resolved]Object Instance Error

    VB Code:
    1. 'from the AlphaNumericButton usercontrol
    2. Public Function getChr() As String
    3.        If IsAlphabetic = False Then
    4.            getChr = strDigitValue
    5.        Else
    6.            If keyPadTimer.Enabled = True Then
    7.               'supposed to be working with this bit
    8.                Dim tmpArray() As String
    9.                Dim i As Integer
    10.                For i = 0 To Len(strAlphaValue)
    11.                    tmpArray(i) = strAlphaValue.Substring(i, 1)
    12.                Next
    13.                For i = 0 To tmpArray.Length
    14.                    MsgBox(tmpArray(i))
    15.                Next
    16.                getChr = ""
    17.                'end this bit
    18.            Else
    19.                If strAlphaValue.Length > 0 Then
    20.                    getChr = strAlphaValue.Substring(0, 1)
    21.                Else
    22.                    getChr = " "
    23.                End If
    24.            End If
    25.        End If
    26.    End Function
    27.  
    28.  
    29.  
    30.  
    31.  
    32. Private Sub btnKey2to9Handler(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKey2.Click, btnKey3.Click
    33.  
    34.        If armed = True Or expectingInput = True Then
    35.            Static KeyValue As String
    36.            MsgBox(sender.name)
    37.            If Not lastKeyPressed Is sender Then
    38.                AlphaNumericButton.keyPadTimer.Enabled = False
    39.            End If
    40.            lastKeyPressed = sender
    41.  
    42.            If AlphaNumericButton.IsAlphabetic = False Then
    43.                KeyValue = sender.Getchr
    44.            Else
    45.  
    46.               'Working with this part
    47.                If Not AlphaNumericButton.keyPadTimer.Enabled Then
    48.                    KeyValue = sender.Getchr
    49.                    AlphaNumericButton.keyPadTimer.Enabled = True
    50.                Else
    51.                    'Delete the last alpha character.
    52.                    If inputBuffer.Length > 0 Then
    53.                        inputBuffer = inputBuffer.Substring(0, inputBuffer.Length - 1)
    54.                    End If
    55.                    'Determine the next alpha character.
    56.  
    57.                    'Errors here if I click within one second
    58.                    MsgBox(sender.Getchr)
    59.                End If
    60.            End If
    61.  
    62.        End If
    63.    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,


    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?
    Last edited by Pc_Madness; May 17th, 2004 at 05:12 AM.
    Don't Rate my posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width