Random VB code thread. (8)

5 Name: Pab!aCLsG89omI 2004-12-07 23:33 ID:Xj14prtA [Del]

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Sub Main()

Dim hdc As Long, hPen As Long, hOld As Long, x As Long, y As Long
hdc = GetDC(0)

Randomize Timer
For x = 0 To 99999

DoEvents

hPen = CreatePen(CInt(Rnd * 3), CInt(Rnd * 5) + 1, RGB(CInt(Rnd * 255), CInt(Rnd * 255), CInt(Rnd * 255)))
hOld = SelectObject(hdc, hPen)
LineTo hdc, Rnd * (Screen.Width / Screen.TwipsPerPixelX), Rnd * (Screen.Height / Screen.TwipsPerPixelY)
Call SelectObject(hdc, hOld)
DeleteObject hPen

Next x

End Sub

This thread has been closed. You cannot post in this thread any longer.