VB Code:
Private Declare Function GetTickCount& Lib "kernel32" ()
Private Function RealRand(Lowb As Integer, upb As Integer) As Long
Dim T As Long
Dim P As Integer, Q As Single
Randomize
T = GetTickCount
Do Until T >= Lowb And T <= upb
Q = (Rnd * 100) + 1
T = T / Q
DoEvents
' T = T / Int(upb - Lowb) * Rnd
If T < Lowb Then
T = upb * Rnd
End If
Loop
RealRand = T
End Function
Private Sub Form_Load()
Dim Arr(500) As Byte, K As Long, Q As Long
Me.ScaleMode = vbPixels
Picture1.ScaleMode = vbPixels
Picture1.Width = 500
Picture1.Height = 125
Picture1.AutoRedraw = True
Show
DoEvents
Do
' Get random value
'K = RealRand(0, 500)
K = Fix(500 * Rnd)
' Increment color
Arr(K) = Arr(K) + 1
' draw line
Picture1.Line (K, 0)-(K, Picture1.ScaleHeight), RGB(Arr(K), Arr(K), Arr(K))
' Finish if reached 255
If Arr(K) = 255 Then Exit Do
Q = Q + 1
If (Q Mod 10) = 0 Then Picture1.Refresh
Loop
For K = 0 To 500
Picture1.Line (K, 0)-(K, Picture1.ScaleHeight), RGB(Arr(K), Arr(K), Arr(K))
Next K
Picture1.Refresh
MsgBox "Done !"
End Sub