how to validate textbox from accepting duplicates and combo box from displaying dupli

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • imoroyussif640
    New Member
    • Apr 2014
    • 1

    how to validate textbox from accepting duplicates and combo box from displaying dupli

    I have a text box which will be use accept the input,
    combo box for displaying the output.
    Now, i some codes that will be use to prevent me from entering
    repeated numbers into the text box and also i need some codes to prevent the combo box from displaying the output.thanks
  • Luk3r
    Contributor
    • Jan 2014
    • 300

    #2
    Instead of asking what you've tried for such a simple request, I'm just going to provide you with something. You can modify it to your liking. I used a textbox, a button, and a combobox. I put this code on my button. I suggest you test it on a new project first.

    Code:
            Dim uniqueItem As String = TextBox1.Text
            Dim uniqueItemsExists As Boolean = False
    
            For Each itm In ComboBox1.Items
                If itm = uniqueItem Then
                    uniqueItemsExists = True
                End If
            Next
    
            If uniqueItemsExists = False Then
                ComboBox1.Items.Add(uniqueItem)
            End If

    Comment

    Working...