|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Function boolSkip(m As Long, n As Long, boolRand As Boolean)
' Procedure : boolSkip
' Description: Return TRUE if we should skip this time.
' Copyright: Chris Greaves Inc.
' Inputs: Long sample size
' Long universe size
' Boolean "random sampling or not".
' Returns: Boolean tru if we should skip this entry.
' Assumes: Nothing
' Side Effects: None.
' Tested: By the calls shown below.
' Return TRUE if we should skip this time.
' User has opted to use m out of every n entries.
' User may have opted to choose at random.
' Useful for sampling files from a list of files.
Static lngRecords As Long
If boolRand Then
If Rnd <= m / n Then
boolSkip = False
Else
boolSkip = True
End If
Else
If lngRecords >= m Then
boolSkip = True
Else
boolSkip = False
End If
lngRecords = lngRecords + 1
If lngRecords >= n Then
lngRecords = 0
End If
End If
'Sub TESTboolSkip()
'Dim inti As Integer
'MsgBox "start of serial sampling"
'For inti = 1 To 6
' MsgBox boolSkip(1, 5, False)
'Next inti
'MsgBox "start of random sampling"
'For inti = 1 To 6
'MsgBox boolSkip(1, 5, True)
'Next inti
'End Sub
End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |