LISTING 1a:
This small VB program draws randomly colored lines all over the application window.

                              Option Explicit                              Sub Form_Load ()                              	Randomize		'Init random number generator                              	DrawWidth = 2		'Set line width to 2                              End Sub                              Sub Timer1_Timer ()                              	Dim R, G, B, X2, Y2                              	'Create random RGB colors                              	R = 255 * Rnd                              	G = 255 * Rnd                              	B = 255 * Rnd                              	'Set end point of line to random spot on form                              	X2 = Int(DemoForm.Width * Rnd + 1)                              	Y2 = Int(DemoForm.Height * Rnd + 1)                              	Line -(X2, Y2), RGB(R, G, B)                              End Sub                              

LISTING 1b:
This small Delphi program has almost a one-for-one correspondence to the VB program (left).

                              procedure TForm1.FormCreate(Sender: TObject);                              begin                              	Randomize;			\{Init random number generator\}                              	Canvas.Pen.Width:= 2;	\{Set drawing width to 2\}                              end;                              procedure TForm1.Timer1Timer(Sender: TObject);                              var                              	R, G, B, X2, Y2: Integer;                              begin                              	\{Create random RGB colors\}                              	R:= Random (256);                              	G:= Random (256);                              	B:= Random (256);                              	Canvas.Pen.Color:= RGB (R, G, B);                              	\{Set end point of line to random spot on form\}                              	X2:= Random (ClientWidth);                              	Y2:= Random (ClientHeight);                              	Canvas.LineTo (X2, Y2);                              end;