Dim intRnDmin As Integer
Dim intRndMax As Integer
Dim intRandom As Integer
intRnDmin = 1
intRndMax = 9
intRandom = Int((intRndMax - intRnDmin + 1) * Rnd + intRnDmin)
Dim snglRnDmin As Single
Dim snglRndMax As Single
Dim snglRandom As Single
snglRnDmin = 100000000000000#
snglRndMax = 999999999999999#
snglRandom = Int((snglRndMax - snglRnDmin + 1) * Rnd + snglRnDmin)
"PLAN B": Create a table with a field to hold the tax-id number. (To make this a bit easier you could have a second field that just holds a pseudo record number.) Count the number of records with dcount. Also implicit is that the tax-id number is identified by (associated with) the record number. Design your random number generator to create random numbers from 1 to the total number of tax-ids. So if record #5 is selected by the random number generator you pull out tax-id number ZZZZ.I can't rethink of the created number as this is a MUST (by Tax authority).
I was afraid of getting that answer. I was expecting that you were randomly selecting a (15 digit) tax-id number rather than generating a random number of 15 digits.they require me to create a 15 characters long random number. this number must be pure random.
Public Function ExtractDigits(Anystring As String) As String
Dim i As Integer
Dim sStr As String
For i = 1 To Len(AnyString)
If IsNumeric(Mid(AnyString,i,1)) Then
sStr = sStr & Mid(AnyString,i,1)
End If
Next
ExtractDigits = Left(sStr,15)
End Function
Dim snglRnDmin As Long
Dim snglRndMax As Long
Dim strRandom As String
Dim i As Integer
snglRnDmin = 0
snglRndMax = 9
strRandom = ""
For i = 1 To 15
strRandom = strRandom & Int((snglRndMax - snglRnDmin + 1) * Rnd + snglRnDmin)
Next i
with or without the Randomize both generate the same resultRnd Function Example
This example uses the Rnd function to generate a random integer value from 1 to 6.
Dim MyValue
MyValue = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.
Randomize Statement Example
This example uses the Randomize statement to initialize the random-number generator. Because the number argument has been omitted, Randomize uses the return value from the Timer function as the new seed value.
Dim MyValue
Randomize ' Initialize random-number generator.
MyValue = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.
The Rn function returns a pseudo-random real number between 0 and 1.what is the length of the original random number ?
Did you do the tests in the same session or in different sessions?won't the Rnd function generate different results each time it runs without the Randomize ?
my tests show it does.
Dim snglRnDmin As Long
Dim snglRndMax As Long
Dim strRandom As String
Dim i As Integer
snglRnDmin = 0
snglRndMax = 9
strRandom = ""
For i = 1 To 15
strRandom = strRandom & Int((snglRndMax - snglRnDmin + 1) * Rnd + snglRnDmin)
Next i