0
这必须是微不足道的。我这样做是为生活和想不通为什么我收到此异常:VB.NET-文本框的更改.Text属性抛出空引用异常
System.NullReferenceException了未处理消息=对象引用 不设置到对象的实例。
下面是代码:
Public Class frmMain
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim counties() As String
counties = {"", "Huntsville, AL", "Madison, AL", "Rural Madison County, AL", "Taft, TN"}
Me.cbCounties.DataSource = counties
Me.lblStatus.Text = "[ Please select a county ]"
Me.lblStatus.Left = Me.ClientSize.Width \ 2 - Me.lblStatus.Width \ 2
End Sub
Private Sub cbCounties_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbCounties.SelectedIndexChanged
Select Case cbCounties.SelectedIndex
Case 1
txtTaxRate.Text = "8.00%" 'Issue is these, when index is changed.
Case 2
txtTaxRate.Text = "8.50%"
Case 3
txtTaxRate.Text = "5.50"
Case 4
txtTaxRate.Text = "9.50%"
Case Else
txtTaxRate.Text = Nothing
End Select
Me.lblStatus.Text = "[ Please enter net amount ]"
Me.lblStatus.Left = Me.ClientSize.Width \ 2 - Me.lblStatus.Width \ 2
End Sub
末级
帮助?
在哪里抛出的异常? – 2012-08-16 04:36:10
查看代码中的评论。具体来说,它被引用到select case语句中,引用txtTaxRate TextBox – 2012-08-16 04:37:06
这是在你改变了几次之后?设置txtTaxRate = Nothing,稍后尝试将txtTaxRate.Text设置为其他内容会导致一些问题。尝试更改txtTaxRate = Nothing to txtTaxRate.Text =“” – 2012-08-16 04:38:15