devxlogo

For…Next Loop Speedup

For…Next Loop Speedup

Whenever you use For.Next loops, it is faster NOT to use the countername after Next (of the For.Next loop). In nested loops, it produces significantlyfaster code.

 Sub Form_Load ()Dim TStart!Dim I As IntegerTStart! = Timer	For I = 1 To 32000	Next IDebug.Print Timer - TStart!TStart! = Timer	For I = 1 To 32000	Next ' I ' For readability, it is better 		' to show the counter name 		' by commenting it out. Debug.Print Timer - TStart!End Sub
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist