close... after setting your boolean when you find the duplicate, you need to exit the for loop... otherwise when it checks the next number, it DOESN'T match and it re-sets your boolean.
The alternative is to set the boolean to FALSE before you start you loop AND ONLY change it when you find a match.
or both... which is probably how I'd do it given the code you have.
\-tgCode:Dim FoundDuplicate as boolean While (i < 28) Geçici(i) = RandomSayi(0, 80) FoundDuplicate = False 'assume no duplicate For k = 0 To i - 1 Step 1 If (Geçici(i) = Geçici(k)) Then FoundDuplicate = True ' set a flag showing we found a duplicate exit For ' this exits the for loop... since we found a duplicate, there's no point in checking the rest. End If Next k If not FoundDuplicate Then 'if no duplicate was found Kalıcı(i) = Geçici(i) lbIndis.AddItem (Str(Kalıcı(i))) i = i + 1 ' move on to the next one End If Wend




Reply With Quote