我有一个vb.net程序,该程序可以跟踪购买抽奖券的人,也可以跟踪其电话号码。当我去添加一个新的人时(通过for循环),它获得了他们购买的门票数量,并将那个名字和数量添加到一个数组中。但是,当我单击它时,它会添加我输入的prevoius名称和数字中的一个。
我尝试移动发生变量分配的地方。 我试图使变量为空并重新分配它。
按钮单击
Public Sub BtnAddtckt_Click(sender As Object, e As EventArgs) Handles
BtnAddtckt.Click
Reset()
Dim MNES As String = Nameinput.Text.ToString
Dim NUMES As String = Numinput.Text.ToString
Dim LenPrev = ApplicantsName.Length - 1
Dim LenNext = (LenPrev) + (NumEntries.Value - 1)
ReDim Preserve ApplicantsName(LenNext)
ReDim Preserve ApplicantsNum(LenNext)
For Subs As Integer = LenPrev To LenNext
ApplicantsNum(Subs) = NUMES
ApplicantsName(Subs) = MNES
Next
LbltotalRegistered.Text = (ApplicantsName.Length - 1).ToString
For nme As Integer = 0 To (ApplicantsName.Length - 1)
Form2.LBname.Items.Add(ApplicantsName(nme).ToString)
Next
For nem As Integer = 0 To (ApplicantsNum.Length - 1)
Form2.LBnum.Items.Add(ApplicantsNum(nem).ToString)
Next
End Sub
我希望它不会在每个敬畏中增加一个额外的人。