我收到此错误“对象引用未设置为对象实例".有人知道如何解决这个问题吗? [英] I'm getting this error "object reference not set to an instance of an object" can somebody know how to fix this?
本文介绍了我收到此错误“对象引用未设置为对象实例".有人知道如何解决这个问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim LookAhead() As Char
Dim Counter As Integer
Dim Character() As String
'Method to scan input
Public Sub LexicalAnalyzer()
Dim Length As Integer
Index = 0
Length = Len(RichTextBoxInput.Text)
Dim i As Integer = 0
Try
Dim InputLength As Integer
InputLength = Len(RichTextBoxInput.Text)
Do While i <= InputLength
LookAhead = RichTextBoxInput.Text.Substring(i)
If Mid(LookAhead, 1, 1) = " " Then
MsgBox("hghghgkj")
Index = Index + 1
Else
'The error is in this part
Character(Index) = Mid(LookAhead, 1, 1)
MsgBox(Character(Index))
End If
i = i + 1
Loop
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
推荐答案
是的.通过调试器运行它,您可以轻松找到并自行修复.您正在尝试使用一个为空的对象,或者在一个为空的对象上调用方法.
Yes. Running this through the debugger, you could easily find this and fix it yourself. You are trying to use an object that is null or call a method on an object that is null.
这篇关于我收到此错误“对象引用未设置为对象实例".有人知道如何解决这个问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文