KelvinN.
New member
Am trying to remove this error: Object reference not set to an instance of an object - what causes this error?
When the contextMenuStrip appears, and I put this code on it here it never works:
I get this error:
VB.NET:
''''' Remove words in Angle Brackets
Private Function GetWordWithOutBracketedText(SelectedReplacement As String) As String
' check if the selected replacement contains bracket "("
If Strings.InStr(SelectedReplacement, " (") = 0 Then
Return SelectedReplacement ' if not exists return the same string back
End If
' if bracket is there in string split it with bracket
Dim arr() As String = Strings.Split(SelectedReplacement, " (")
' send back the first element from splitted array as only first part is the replacement text
Return arr(0)
End Function
VB.NET:
Private Sub ContextMenuStrip1_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
RichTextBox1.SelectedText = GetWordWithOutBracketedText(kamau)
End Sub
I get this error:
VB.NET:
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.
Last edited: