很好奇为什么在尝试在 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
如果有人解释我收到此错误的原因,我将不胜感激。