删除列表框vb.net中的最后一项

时间:2017-06-13 07:27:29

标签: vb.net

我正在开发一个项目,我需要文本框的名称和年龄,当你点击商店数据时,它将它放入一个数组中,当这个人做的时候,他们点击列表全部(这将显示列表框中的所有项目) 。我的问题是年龄限制是1-100,当它低于或低于。它说错误消息租用者年龄,但那里的类型的年龄仍然存储在数组中,因此在列表框中显示如何阻止该有效年龄存储在数组中并显示在列表框中。我把目前的代码放到了下面。谢谢。

    Dim Ages As String
    Dim Surnames As String

    Surnames = txtNames.Text
    Ages = txtAge.Text

    If txtNames.Text = "" Then

        MsgBox("Enter Name ")
        txtNames.Focus()
        SystemValueAge = SystemValueAge - 1
        SystemValueName = SystemValueName - 1
        txtNames.Focus()

    ElseIf txtAge.Text = "" Then

        MsgBox("Enter Age")
        SystemValueAge = SystemValueAge - 1
        SystemValueName = SystemValueName - 1
        txtAge.Focus()

    ElseIf Ages < 1 Or Ages > 100 Then

        MsgBox("Please Enter Valid Age")
        SystemValueAge = SystemValueAge - 1
        SystemValueName = SystemValueName - 1
        ListBoxShow.Items.RemoveAt(ListBoxShow.Items.Count - 1)
        txtAge.Focus()

    End If

    Dim List As Integer

    If RBName.Checked = True Then

        ListBoxShow.Items.Clear()
        For List = 1 To SystemValueName

            ListBoxShow.Items.Add(Surname(List))

        Next

    End If

    If RBage.Checked = True Then

        ListBoxShow.Items.Clear()
        For List = 1 To SystemValueAge

            ListBoxShow.Items.Add(Age(List))

        Next

    End If

End Sub

0 个答案:

没有答案
相关问题