Results 1 to 2 of 2

Thread: [RESOLVED] Handles clause requires a WithEvents

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Resolved [RESOLVED] Handles clause requires a WithEvents

    I am trying to follow this thread

    http://www.vbforums.com/showthread.p...ght=spellcheck

    and I have it pretty close but have one error.

    Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
    That error is on both of these, in blue
    Code:
    Private Sub SpellChecker1_DeletedWord(ByVal sender As Object, ByVal e As NetSpell.SpellChecker.SpellingEventArgs) Handles SpellChecker1.DeletedWord
            'save existing selecting
            Dim activeRichTextBox = TryCast(Me.ActiveControl, RichTextBox)
            Dim start As Integer = activeRichTextBox.SelectionStart
            Dim length As Integer = activeRichTextBox.SelectionLength
    
            'select word for this event
            activeRichTextBox.Select(e.TextIndex, e.Word.Length)
    
            'delete word
            activeRichTextBox.SelectedText = ""
    
            If ((start + length) > activeRichTextBox.Text.Length) Then
                length = 0
            End If
    
            'restore selection
            activeRichTextBox.Select(start, length)
    
        End Sub
    
        ' Handles replacing a word from spell checking
        Private Sub SpellChecker1_ReplacedWord(ByVal sender As Object, ByVal e As NetSpell.SpellChecker.ReplaceWordEventArgs) Handles SpellChecker1.ReplacedWord
            'save existing selecting
            Dim activeRichTextBox = TryCast(Me.ActiveControl, RichTextBox)
            Dim start As Integer = activeRichTextBox.SelectionStart
            Dim length As Integer = activeRichTextBox.SelectionLength
    
            'select word for this event
            activeRichTextBox.Select(e.TextIndex, e.Word.Length)
    
            'replace word
            activeRichTextBox.SelectedText = e.ReplacementWord
    
            If ((start + length) > activeRichTextBox.Text.Length) Then
                length = 0
            End If
    
            'restore selection
            activeRichTextBox.Select(start, length)
        End Sub
    I have added the reference, I have also added them to the toolbox. My dictionary is all set. What did I miss?

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: Handles clause requires a WithEvents

    lol, I fixed this error. Changed SpellChecker1 to Spelling1

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