VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3495
ClientLeft = 60
ClientTop = 1530
ClientWidth = 11790
LinkTopic = "Form1"
ScaleHeight = 3495
ScaleWidth = 11790
Begin VB.TextBox Text7
Height = 375
Left = 6360
Locked = -1 'True
TabIndex = 8
Text = "Text7"
Top = 240
Width = 1455
End
Begin VB.TextBox Text6
Height = 375
Left = 4320
Locked = -1 'True
TabIndex = 7
Text = "Text6"
Top = 840
Width = 1455
End
Begin VB.TextBox Text5
Height = 375
Left = 4320
Locked = -1 'True
TabIndex = 6
Text = "Text5"
Top = 240
Width = 1455
End
Begin VB.TextBox Text4
Height = 375
Left = 2280
Locked = -1 'True
TabIndex = 5
Text = "Text4"
Top = 840
Width = 1455
End
Begin VB.TextBox Text3
Height = 375
Left = 2280
Locked = -1 'True
TabIndex = 4
Text = "Text3"
Top = 240
Width = 1455
End
Begin VB.TextBox Text2
Height = 375
Left = 240
Locked = -1 'True
TabIndex = 3
Text = "Text2"
Top = 840
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 240
Locked = -1 'True
TabIndex = 2
Text = "Text1"
Top = 240
Width = 1455
End
Begin VB.Label Label2
BackColor = &H80000001&
Caption = " "
Height = 375
Left = 240
TabIndex = 1
Top = 1440
Width = 11415
End
Begin VB.Label Label1
BackColor = &H80000009&
Caption = " "
Height = 375
Left = 240
TabIndex = 0
Top = 1440
Width = 11415
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim n As Integer
Dim a() As Boolean
Private Sub Form_Click()
Dim id As Integer
Dim r(5000000) As Integer
Dim i As Long, j As Long
Dim b As Boolean
Dim s As Long
Dim c As Integer
For j = 1 To 7
Me("text" & j).Text = ""
Next j
For n = 30 To 60 Step 5
ReDim a(n - 1) As Boolean
For j = 0 To 5000000
r(j) = 0
Next
For i = 0 To 5000000
For j = 0 To n - 1
a(j) = False
Next j
Do
b = False
For j = 0 To 2
Randomize
id = Int(Rnd() * n)
If a(id) = False Then
b = True
a(id) = True
Exit For
End If
Next
Loop Until b = False
For j = 0 To n - 1
r(i) = r(i) + IIf(a(j) = True, 1, 0)
Next j
If i Mod 50000 = 0 Then
Label2.Width = Label1.Width * i / 5000000#
DoEvents
End If
Next i
s = 0
For j = 0 To 5000000
s = s + r(j)
Next j
If Me.CurrentY > Me.ScaleHeight - 600 Then
c = c + 1
CurrentY = 0
End If
CurrentX = c * 2000
Me("text" & CStr(n / 5 - 5)).Text = n & ": " & s / (n * 5000001#)
Next n