注册 登录
编程论坛 VB.NET论坛

求助,高手请赐教

jonebob 发布于 2008-08-12 13:47, 758 次点击
是这样,我想通过四个textbox输入,然后输入到listbox中,现在的要求是,每一次输入后,必须保证四个textbox的内容与listbox中(以前输入过的内容不同才能输入listbox中)
或者说是如何通过判断listbox的内容的相同与否实现。谢谢!
2 回复
#2
fairy42008-08-12 20:11
汗,這個也要叫高手,現在的人,越來越不想自己動手了.哎!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As Integer = Me.ListBox1.Items.Count
        Dim strTemp, strTemp01, strTemp02, strTemp03, strtemp04 As String
        Dim flag As Boolean = False
        strTemp01 = Me.TextBox1.Text
        strTemp02 = Me.TextBox2.Text
        strTemp03 = Me.TextBox3.Text
        strtemp04 = Me.TextBox4.Text
        If x = 0 Then
            Me.ListBox1.Items.Add(strTemp01)
            Me.ListBox1.Items.Add(strTemp02)
            Me.ListBox1.Items.Add(strTemp03)
            Me.ListBox1.Items.Add(strtemp04)
        Else

            For i As Integer = 0 To x - 1
                strTemp = Me.ListBox1.Items(i).ToString
                If strTemp01 = strTemp Or strTemp02 = strTemp Or strTemp03 = strTemp Or strtemp04 = strTemp Then
                    flag = True
                End If
            Next
            If flag = False Then
                Me.ListBox1.Items.Add(strTemp01)
                Me.ListBox1.Items.Add(strTemp02)
                Me.ListBox1.Items.Add(strTemp03)
                Me.ListBox1.Items.Add(strtemp04)
            End If

        End If


    End Sub
#3
jonebob2008-08-13 09:23
太强大了,谢谢,看来是我太低手........向高手致意,学习
1