【发布时间】:2013-01-01 23:17:10
【问题描述】:
我可以向array(0) 添加一个值,但是当我向array(1) 添加一个值时,它会清除array(0) 的值。我已经尝试了所有我能想到的方法来声明和创建数组。我的代码如下所示:
Dim aryEstimateInfo() As String = New String(7) {}
Private Sub wzrdEstimateWizard_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles wzrdEstimateWizard.NextButtonClick
Select Case wzrdEstimateWizard.ActiveStepIndex
Case 0 'first estimate wizard step
aryEstimateInfo(0) = rad_lstVehicleType.SelectedItem.ToString
Case 1 'second estimate wizard step
Dim DamageZoneSelected As Boolean = False
For Each cntrl As Control In pnlDamageZone.Controls
If TypeOf cntrl Is RadioButton Then
Dim RadButton As RadioButton = cntrl
If RadButton.Checked Then
DamageZoneSelected = True
DamageZone = RadButton.Text.ToString
Exit For
Else
DamageZoneSelected = False
End If
End If
Next
If DamageZoneSelected = True Then
lblDamageZoneError.Visible = False
aryEstimateInfo(1) = DamageZone
Else
'if no damage zone is selected a message is displayed
wzrdEstimateWizard.ActiveStepIndex = 2
wzrdEstimateWizard.ActiveStepIndex = 1
lblDamageZoneError.Visible = True
End If
Case 2 'third estimate wizard step
'assigns the number of dents to the estimate array
aryEstimateInfo(2) = ddlNumberOfDents.SelectedValue.ToString
'sets the average dent size in the estimate arrau
aryEstimateInfo(3) = ddlDentSize.SelectedValue.ToString
'sets the add-on code and number of oversized dents
If ddlOverSized.Enabled = True Then
'aryEstimateInfo.SetValue("3", 4)
aryEstimateInfo(4) = "3"
aryEstimateInfo(7) = ddlOverSized.SelectedValue.ToString
Else
End If
Case 3 'fourth estimate wizard step
Case Else
End Select
End Sub
我在 ASP.Net 向导控件和基本的 Visual Studio 2010 中使用它。
【问题讨论】:
-
您是否尝试过调试?你确定 array(0) 的值没有在该特定行之前的某处被清除吗?
-
您能在向导的第 1 步和第 2 步中显示代码吗?
-
我用我使用的代码更新了原始帖子
-
我唯一使用该数组的其他代码是我试图在标签中显示这些值:Label1.Text = aryEstimateInfo(0) - 在主要声明中我有这个:Dim aryEstimateInfo () 作为字符串 = 新字符串 (7) {}
-
认为我们已经解决了这个问题,谢谢大家
标签: asp.net arrays vb.net visual-studio-2010