I want to block duplicating data entry by comparing the data from listbox.
dim promoEnded As Boolean = False
dim o as Integer
for o=ListBox1.Listcount downto 0
dim gg as integer
for gg=0 to Listbox5.Listcount -1
if ListBox1.selected(o) then
If Listbox1.cell(o,1)=Listbox5.cell(gg,0) then
MessageBox "Barcode exist"
exit for
end if
end if
next
next
the code is working but way to slow.
is there any simple code that can do the process faster?
Create a dictionary where you buffer the contents of Listbox5 column 0 when filling it and compare your entry against this. Comparison should be much faster as a dictionary uses hash values to find its key values.
If you fill the list boxes one after the other, create the first list and write each entry also into the dictionary. For the second list, you only add the entries that are not yet in the dictionary.