Skip to main content
gamedev.net
🔒 Locked

Visual basic doubt

Started by manu1510 2 replies 700+ views
Original Post
manu1510
manu1510
I know that it is possible to create an array of components in VB like cmd1(0), cmd1(1), cmd1(2) e.t.c. But suppose I need to arrange 9 command buttons in a 3X3 square, is it possible to name them in the following manner cmd1(0)(0) cmd1(0)(1) cmd1(0)(2) cmd1(1)(0) cmd1(1)(1) cmd1(1)(2) cmd1(2)(0) cmd1(2)(1) cmd1(2)(2) If possible, how should it be done? Please help.
vogela
vogela
I have never tried multi dimensional arrays with controls, but VB uses the following syntax for multiple dimensions:

cmd(0,0) cmd(0,1)...
cmd(1,0)...
.
.
.
manu1510
manu1510
Thanks a lot for this help, but can anyone tell me how to create a set of command buttons (or any other component) in VB with names in this format?
ItsDoh
ItsDoh
"Control Arrays" in VB can't have multiple dimensions. You can either write some easy routines to convert a 1d index into the 2d index, and vice versa, or you can make the array simply as an array of the control in code, making use of the controls collection of the form.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.