Hello im a college student learning VB.net and im trying to optimize a bit of code and could use some help.
I created 81 textboxes in my form named textbox0, textbox1, . . . , textbox80.
I also have a 2D array called Game(8,8) as Textbox.
Heres my current code:
Game(0,0) = Textbox0
Game(0,1) = Textbox1
Game(0,2) = Textbox2
.
.
.
Game(8,8) = Textbox80
I would like a loop that automatically increments the numeric digits at the end of Textbox object name. Something along the lines of:
Dim Row As Integer
Dim Column As Integer
Dim intCount As Integer = 0
For Row = 0 To 8
For Column = 0 To 8
Game(Row, Column) = "txt" & intCount
Count += 1
Next
Next
Copy and paste got me through the first 81 textboxes of this project, but i want to expand the number of textboxes to a 16 x 16 grid, giving 256 total.
Ive tried to research this problem, but feel like a a kid that doesn't know that the word "pharmacy" starts with a "P" and his teacher says to look it up in a dictionary, lol. I have found several threads on creating dynamic control instances. All my instances where created and placed in the design view, i just need to bind them to my array.
For context, I'm trying to make a very generic Sudoku game ap.
Thanks for any help offered.
I created 81 textboxes in my form named textbox0, textbox1, . . . , textbox80.
I also have a 2D array called Game(8,8) as Textbox.
Heres my current code:
Game(0,0) = Textbox0
Game(0,1) = Textbox1
Game(0,2) = Textbox2
.
.
.
Game(8,8) = Textbox80
I would like a loop that automatically increments the numeric digits at the end of Textbox object name. Something along the lines of:
Dim Row As Integer
Dim Column As Integer
Dim intCount As Integer = 0
For Row = 0 To 8
For Column = 0 To 8
Game(Row, Column) = "txt" & intCount
Count += 1
Next
Next
Copy and paste got me through the first 81 textboxes of this project, but i want to expand the number of textboxes to a 16 x 16 grid, giving 256 total.
Ive tried to research this problem, but feel like a a kid that doesn't know that the word "pharmacy" starts with a "P" and his teacher says to look it up in a dictionary, lol. I have found several threads on creating dynamic control instances. All my instances where created and placed in the design view, i just need to bind them to my array.
For context, I'm trying to make a very generic Sudoku game ap.
Thanks for any help offered.