Platforms to show: All Mac Windows Linux Cross-Platform
FAQ.How to do a lottery in RB?
Sub Lotto(max as Integer,count as Integer,z() as Integer) // Lotto count numbers of max put into the array z beginning at index 0 dim n(0) as Integer ' all the numbers dim m as Integer ' the highest field in the current array dim i,a,b,d as Integer ' working variables 'fill the array with the numbers m=max-1 redim n(m) for i=0 to m n(i)=i+1 next ' unsort them by exchanging random ones m=max*10 for i=1 to m a=rnd*max b=rnd*max d=n(a) n(a)=n(b) n(b)=d next ' get the first count to the dest array m=count-1 redim z(m) for i=0 to m z(i)=n(i) next 'sort the result z.sortEnd SubSub Open() // Test it dim za(0) as Integer ' the array of the numbers lotto 49,6,za ' 6 of 49 in Germany ' and display them staticText1.text=str(za(0))+chr(13)+str(za(1))+chr(13)+str(za(2))+chr(13)+str(za(3))+chr(13)+str(za(4))+chr(13)+str(za(5))+chr(13)End Sub