Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please anyone help me i am getting error object reference not set to an instance of an object on this line Me.spellingError = Me.UltraSpellChecker1.GetErrorAtPoint(txt, New Point(e.X, e.Y))

What I have tried:

C#
Private Sub txtSpelling_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtActivityDesc.MouseDown

        Try
            Dim txt As TextBox = DirectCast(sender, TextBox)

            If Not txt.Focused Then
                txt.Focus()
                SendKeys.Send("{HOME}")
            End If

            If e.Button = System.Windows.Forms.MouseButtons.Right Then
                Me.spellingError = Me.UltraSpellChecker1.GetErrorAtPoint(txt, New Point(e.X, e.Y))
                ' If there is no spelling error at the designated coordinates, clear the context menu and cancel.
                If spellingError Is Nothing Then
                    Me.CMenuSpell.Items.Clear()

                    Me.CMenuSpell.Items.Add(New ToolStripMenuItem("Spell Check", Nothing, New System.EventHandler(AddressOf mSpellChk_Click)))

                    Me.CMenuSpell.Items.Add(New ToolStripSeparator)
                    Me.CMenuSpell.Items.Add(New ToolStripMenuItem("Lower Case (All)", Nothing, New System.EventHandler(AddressOf mLower_Click)))
                    Me.CMenuSpell.Items.Add(New ToolStripMenuItem("Upper Case (All)", Nothing, New System.EventHandler(AddressOf mUpper_Click)))

                    Return
                Else
                    Me.PopulateCMenuonErr(spellingError)
                End If

            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message & vbCrLf & vbCrLf & "[ Error Code ]    " & GetCurrentMethod.Name & " ()", MsgHeader, MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try
    End Sub
Posted
Updated 29-Nov-16 21:56pm

Debug your application and move your mouse over the offending line and watch the values in the tooltip for nulls/nothing, and work backward from there to fix things.
 
Share this answer
 
Comments
nadeemforn 30-Nov-16 5:26am    
its showing nothing... what i do now?
Mehdi Gholam 30-Nov-16 5:31am    
Somewhere your "nothing" object should be set to something (created/new-ed) find the place and fix it.
nadeemforn 30-Nov-16 5:46am    
Me.spellingError = Me.UltraSpellChecker1.GetErrorAtPoint(txt, New Point(e.X, e.Y))

this line is getting error
nadeemforn 30-Nov-16 5:29am    
how to fix it?
nadeemforn 30-Nov-16 5:42am    
i just copy this code from another project but don't know how to fix this problem plz help me
Your code show that you use the variable Me but where does it come from ?
Use the debugger to inspect variables while your code is running.

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 
Comments
nadeemforn 30-Nov-16 6:09am    
i just need help can you?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900