"n" is the textbox number (eg textbox1, textbox2... textboxn)"g" is the row the textbox should end up in"r" is the column the textbox should end up in

The textboxes are 20x20, and are being aligned in a 400x400 grid in 20 rows and columns. All the code is in Form1_Load.

My issue comes, that VB doesn't like me putting "textbox(n)" (I've tried "textboxn" too), as it is trying to read it as a variable called "Textboxn". Is there a way to do this without angering the programming language?

I'm on my lunch break, but I'll try to go through it more thoroughly and see if I can get it to work.

I've found another way of doing it, which involves a loop that creates the textbox in the code (instead of just creating them in the designer, like I was before), and then positions them before repeating. It works, I hope I haven't wasted any of your lunch break?

I've found another way of doing it, which involves a loop that creates the textbox in the code (instead of just creating them in the designer, like I was before), and then positions them before repeating. It works, I hope I haven't wasted any of your lunch break?

Thanks for the help!

Learning is never a waste. Generating the controls at runtime then linking them to your array seems a like good way to do this.

Learning is never a waste. Generating the controls at runtime then linking them to your array seems a like good way to do this.

I'm curious what your code is supposed to do.

Ah, good, and yeah it works much better.

The code's the start of a program which will kind of be simulating a game of "Tag". ("Tag" being the children's game where they run around where one of them is "It", until the person who is "It" taps somebody else and the tapped person becomes "It" instead etc).

Each textbox is standing for 1 square metre, and if the person who is "It" is standing in it, the textbox's colour will be red. If another player is standing in it, the colour will be blue.

The idea is that each player is controlled by a few simple rules (eg "If the person who is "It" comes near me, I need to move away from them"), and therefore it should produce some interesting patterns. I'm seeing how realistic I can make the simulation, from a minimal number of iterated rules.

So, in theory, the simulation should be driven by the same kind of maths that makes it possible for flocks of birds to fly in formations and change direction etc, which is a kind of maths that I find quite interesting.

That's interesting. If you finish it and feel like sharing, let me know.

A long time ago I based a similar program on a brain teaser: You have four bugs, each on the corner of a table. Each bug turns towards the one to its right and starts walking towards it. What will be the shape of their paths?

To solve the problem, I wrote a program that had the "bugs" drop markers. Once I was done, I started experimenting with different starting locations and speeds. It made some interesting designs.

That's interesting. If you finish it and feel like sharing, let me know.

A long time ago I based a similar program on a brain teaser: You have four bugs, each on the corner of a table. Each bug turns towards the one to its right and starts walking towards it. What will be the shape of their paths?

To solve the problem, I wrote a program that had the "bugs" drop markers. Once I was done, I started experimenting with different starting locations and speeds. It made some interesting designs.

That sounds like it's based on the same maths as what I'm doing. It is really interesting how weird patterns can be formed by the iteration of really simple rules. I don;t know if you've heard of "Chaos Theory", but that's what this branch of maths is called, basically how systems which feedback on themselves behave.