Re: Generate Number on MS. Access
Thanks alot for all your help! I greatly appreciated!
Lyle Fairfield wrote:
Thanks alot for all your help! I greatly appreciated!
Lyle Fairfield wrote:
The Previous Functions I posted were slightly biased towards making the
first character alpha rather than numeric.
>
I recommend you use the following function which I believe is not.
>
In my previous post I suggested some ways to accomplish what you might
want to do with this function. I think they exhaust my knowledge.
Perhaps, you could look at these, try one or the other and report any
specific problems.
>
Public Function RandomStringA( _
Optional ByVal Dummy As Variant, _
Optional ByVal TemporaryString As String, _
Optional ByVal LettersRemainin gtoGet As Long = 5, _
Optional ByVal NumeralsRemaini ngtoGet As Long = 5)
Dim AsciiCode As Long
If LettersRemainin gtoGet 0 And NumeralsRemaini ngtoGet 0 Then
If Rnd() 0.5 Then
AsciiCode = 65 Or (Round(Rnd(), 0) * 32) _
+ Fix(Rnd() * 26)
LettersRemainin gtoGet = LettersRemainin gtoGet - 1
Else
AsciiCode = 48 + Fix(Rnd() * 10)
NumeralsRemaini ngtoGet = NumeralsRemaini ngtoGet - 1
End If
Else
If LettersRemainin gtoGet 0 Then
AsciiCode = 65 Or (Round(Rnd(), 0) * 32) _
+ Fix(Rnd() * 26)
LettersRemainin gtoGet = LettersRemainin gtoGet - 1
Else
AsciiCode = 48 + Fix(Rnd() * 10)
NumeralsRemaini ngtoGet = NumeralsRemaini ngtoGet - 1
End If
End If
TemporaryString = TemporaryString & Chr$(AsciiCode)
If LettersRemainin gtoGet Or NumeralsRemaini ngtoGet Then
RandomStringA = RandomStringA( _
Dummy, _
TemporaryString , _
LettersRemainin gtoGet, _
NumeralsRemaini ngtoGet)
Else
RandomStringA = TemporaryString
End If
End Function
>
--
Lyle Fairfield
first character alpha rather than numeric.
>
I recommend you use the following function which I believe is not.
>
In my previous post I suggested some ways to accomplish what you might
want to do with this function. I think they exhaust my knowledge.
Perhaps, you could look at these, try one or the other and report any
specific problems.
>
Public Function RandomStringA( _
Optional ByVal Dummy As Variant, _
Optional ByVal TemporaryString As String, _
Optional ByVal LettersRemainin gtoGet As Long = 5, _
Optional ByVal NumeralsRemaini ngtoGet As Long = 5)
Dim AsciiCode As Long
If LettersRemainin gtoGet 0 And NumeralsRemaini ngtoGet 0 Then
If Rnd() 0.5 Then
AsciiCode = 65 Or (Round(Rnd(), 0) * 32) _
+ Fix(Rnd() * 26)
LettersRemainin gtoGet = LettersRemainin gtoGet - 1
Else
AsciiCode = 48 + Fix(Rnd() * 10)
NumeralsRemaini ngtoGet = NumeralsRemaini ngtoGet - 1
End If
Else
If LettersRemainin gtoGet 0 Then
AsciiCode = 65 Or (Round(Rnd(), 0) * 32) _
+ Fix(Rnd() * 26)
LettersRemainin gtoGet = LettersRemainin gtoGet - 1
Else
AsciiCode = 48 + Fix(Rnd() * 10)
NumeralsRemaini ngtoGet = NumeralsRemaini ngtoGet - 1
End If
End If
TemporaryString = TemporaryString & Chr$(AsciiCode)
If LettersRemainin gtoGet Or NumeralsRemaini ngtoGet Then
RandomStringA = RandomStringA( _
Dummy, _
TemporaryString , _
LettersRemainin gtoGet, _
NumeralsRemaini ngtoGet)
Else
RandomStringA = TemporaryString
End If
End Function
>
--
Lyle Fairfield
Comment