Xx...Tazer...xX Owner
Posts : 1239 T®ue Points : 1102678 T®ue Reputation : 40 Join date : 2009-09-02 Age : 31 Location : Chicago,Illinois
| Subject: [VB.NET]Checking For Duplicate Entries in a Combobox Tue Oct 26, 2010 6:04 am | |
| Same thing can be used for a list box. Figure I'd post this since I know this can /will be used alot in programming. Something I had to do for an assignment today actually. - Code:
-
Dim indexinteger As Integer = 0 Dim foundBoolean As Boolean = False Dim listcomparestring As String Dim textcomparestring As String
If catalogsComboBox.Text = "" Then MessageBox.Show("Please enter an item to be added to the list", "Error") catalogsComboBox.Focus()
Else
Do While Not foundBoolean And indexinteger < catalogsComboBox.Items.Count listcomparestring = catalogsComboBox.Items(indexinteger).ToString().ToUpper textcomparestring = catalogsComboBox.Text.ToUpper If listcomparestring = textcomparestring Then catalogsComboBox.SelectedIndex = indexinteger foundBoolean = True MessageBox.Show("Already in the list") Else indexinteger += 1 End If
Loop
If catalogsComboBox.Items.Count = indexinteger Then catalogsComboBox.Items.Add(catalogsComboBox.Text) ClearFocus() End If End If | |
|
Always_Jonezen Site Admin
Posts : 155 T®ue Points : 1015049 T®ue Reputation : 8 Join date : 2010-01-25 Age : 47 Location : NC
| Subject: Re: [VB.NET]Checking For Duplicate Entries in a Combobox Tue Oct 26, 2010 11:31 am | |
| | |
|