Subscribe to Windows IT Pro
February 01, 1996 12:00 AM

VB vs. Delphi: What’s the Difference?

Windows IT Pro
InstantDoc ID #2397
Rating: (1)

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;

Related Content:

ARTICLE TOOLS

Comments
  • Anonymous User
    7 years ago
    Mar 06, 2005

    well, i do love coding with delphi now. i've known vb before, but now that i know delphi more, i find it hard to study and use vb anymore. delphi makes my life a lot easier than vb.

  • yan
    8 years ago
    Jun 16, 2004

    I think, delphi and vb have it's own style. It's really helping me, when I need to finished my project as soon as possible. In my project I've used vb, but in the future I think I'll used delphi. Because Delphi now have the other version that can run in Linux OS (kylix).

  • Renato Azevedo
    8 years ago
    Jun 15, 2004

    I think about this topic, and made a decision that the C++ is better than this 2 examples ;-)

  • jgustavo
    8 years ago
    Apr 28, 2004

    I think Delphi is greatest code for all type applications. And I tried to do many procedures in others languages and no one can make it as Delphi

  • anil
    9 years ago
    Dec 05, 2003

    i think vb coding is more reliable then delphi code

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.