Hi Guys
I try to random fill 2 Listviews with numbers 1-10
Both Lists must have number 1-10, in a Random format for each listview
I keep missing numbers, even when looping a 1000 times
Anysuggestion?
Here is my current code
Thanks
Danie
I try to random fill 2 Listviews with numbers 1-10
Both Lists must have number 1-10, in a Random format for each listview
I keep missing numbers, even when looping a 1000 times
Anysuggestion?
Here is my current code
B4X:
Sub StartBtn_Click
l1.Initialize
l2.Initialize
l1.Clear
l2.Clear
Dim i As Int
For i = 0 To 1000
fillnumber(Rnd(1,11),l1)
Next
For i = 0 To 1000
fillnumber(Rnd(1,11),l2)
Next
End Sub
Sub fillnumber(num As Int, fl As List)
Dim n As Int
Dim ex As String
ex="N"
If fl.Size = 0 Then
fl.Add(num)
End If
If fl.Size < 11 Then
For n=0 To fl.Size-1
fl.Get(n)
If fl.Get(n) = num Then
ex="Y"
End If
Next
If ex="N" Then
fl.Add(num)
Log(num)
End If
End If
End Sub
Thanks
Danie