我想知道在尝试在VB.net中调试我的程序时为什么会出现这个错误。
Object Reference not set to an instance of the object.
它说我的错误是由第4行和第5行引起的:
Public Class Form1
Dim tSize
Dim S1 As String = ComboBox1.Text
Dim S2 As String = ComboBox2.Text
Private Sub FitContents()
tSize = TextRenderer.MeasureText(TextBox3.Text, TextBox3.Font)
TextBox3.Width = tSize.Width + 10
TextBox3.Height = tSize.Height
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = S1
TextBox2.Text = S2
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
Call FitContents()
End Sub
End Class
我非常感激如果有人可以解释一下为什么我会收到这个错误信息。