January 25, 2021
Hot Topics:

Basics of VB Programming

  • By Sam Huggill
  • Send Email »
  • More Articles »

The For..Next statement is an easy way to control program flow. e.g.

Dim i As Integer
Dim iValue As Integer
For i=0 To 10
Next i

In this situation iValue will equal 0 at the start and will increase by 1 every time until it reaches 10.

This can be used to process items from a list box. e.g.

Dim i As Integer
For i=0 To List1.ListCount
List2.AddItem List1.List(i)
Next i

This code copies all the list items from List1 to List2.

Page 4 of 6

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date