samedi 28 mars 2015

How to check if an item is already in a listbox in vb6

I'm working with vb6 and I want to generate multiple randum numbers (the range from to is detirmend by user and also the number of generated answers) and send them to a listbox But I don't want to duplicate generated numbers So.. I want before sending the generated number to the listbox to check if it already exists in the lisbox. if it already exists then generate another number if it does't then send it the the listbox


here is what I have till now max and min are the range to chose numbers between answers is the number of generated numbers



Randomize
For i = 1 To answers Step 1
generated = CInt(Int((max - min + 1) * Rnd() + min))
For n = 0 To List1.ListCount
If List1.List(n) <> gen Then
List1.AddItem (gen)
Else
If List1.List = gen Then
'I don't know what to do from here
'(how to go back to generate another number)
Next n
Next i


Thank you in advance keep in minde I need to keep things simple Thank you soo much





Aucun commentaire:

Enregistrer un commentaire