Generate Really Random Value
Seems VB generate predefined values when use functions RND and RANDOMIZE(6.0), here is minimal improvement which generate You really reandom value...
AI
ملخص الذكاء الاصطناعي: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
كود المصدر
'generate random value between minVal and maxVal inclusive
'or return -1 if any error
Public Function GenerateRandom(minVal As Long, maxVal As Long) As Long
intr = -1
maxVal = maxVal + 1
If maxVal > 0 Then
If minVal >= maxVal Then
minVal = 0
End If
Else
minVal = 0
maxVal = 10
End If
Randomize (DatePart("s", Now) + DatePart("m", Now))
Do While (intr < minVal Or intr = maxVal)
intr = CLng(Rnd() * maxVal)
Loop
GenerateRandom = intr
End Function
Upload
Upload
التعليقات الأصلية (3)
مسترجع من Wayback Machine