Increment an integer variable in a loop

I have "i" that is an integer variable and I would like to do a loop that increments the "i" from 40000 to 90000 adding 1000 each time. Each Result will appear in a ComboBox.

Example: 40000 - 41000 - 42000 - 43000 - ... - 88000 - 89000 - 90000

My code is the following:

var i:integer;
begin
 for i:= 40000 to 90000 do
  begin
   ComboBox1.AddItem(IntToStr(i), nil); //until here the code works
   Inc(i, 1000);                         
  end;

Do you have any suggestions?

Answers


You cannot alter the for loop variable inside the loop.

What you want is this:

for i := 0 to 50 do
  ComboBox1.AddItem(IntToStr(40000 + 1000 * i), nil)

But! This is rather inefficient. You should consider

ComboBox1.Items.BeginUpdate;
for i := 0 to 50 do
  ComboBox1.Items.Add(IntToStr(40000 + 1000 * i));
ComboBox1.Items.EndUpdate;

Need Your Help

Static variable change does not take effect, nodeJS

node.js static static-variables static-functions

I'm writing a little nodeJS based email server. I have a Request object, and in it there's one static variable that stores all the users and is defined like so:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.