How can I read values from multiple textboxes into a 2-D array in VB.NET?

Click For Summary
SUMMARY

This discussion focuses on reading values from multiple textboxes into a 2-D array in VB.NET, specifically a 4x4 matrix. The user attempts to implement this using a nested for/next loop but encounters difficulties in accessing the textbox values. The conversation highlights the challenges of transitioning from VB6 to VB.NET, particularly regarding the absence of control arrays, which complicates the process of managing multiple textboxes. Suggestions include researching alternative methods to create control arrays in VB.NET.

PREREQUISITES
  • Understanding of VB.NET syntax and structure
  • Familiarity with 2-D arrays in programming
  • Basic knowledge of user interface elements in VB.NET
  • Experience with loops and control flow in programming
NEXT STEPS
  • Research how to implement control arrays in VB.NET
  • Learn about handling multiple TextBox controls dynamically in VB.NET
  • Explore the use of collections or lists as alternatives to control arrays
  • Study the use of LINQ for data manipulation in VB.NET
USEFUL FOR

VB.NET developers, software engineers transitioning from VB6, and anyone looking to manage multiple user input fields efficiently in a Windows Forms application.

debwaldy
Messages
34
Reaction score
0
Hi I am a new-comer to VB.Net & I am working with arrays at the moment.i want to write a procedure that accepts two 2-D arrays(max size being a 4*4 matrix).
i don't know how i could get the procedure to read in these values from the sixteen different textboxes i have created...i started using a for/next loop to go through each row as shown below:

Dim i, j, n, m As Integer
Dim a As Double(,)
a = New Double(i, j) {}
For i = 0 To a.GetUpperBound(i)
For j = 0 To a.GetUpperBound(j)
a(i, j) = TextBox

its here that I am stuck i want it to go through each row of textboxes row by row and read in the values input by the user.would some sort of inner loop again work...or is there a much easier way to do this...any help is much appreciated :biggrin:
 
Computer science news on Phys.org
debwaldy said:
Hi I am a new-comer to VB.Net & I am working with arrays at the moment.i want to write a procedure that accepts two 2-D arrays(max size being a 4*4 matrix).
i don't know how i could get the procedure to read in these values from the sixteen different textboxes i have created...i started using a for/next loop to go through each row as shown below:

Dim i, j, n, m As Integer
Dim a As Double(,)
a = New Double(i, j) {}
For i = 0 To a.GetUpperBound(i)
For j = 0 To a.GetUpperBound(j)
a(i, j) = TextBox

its here that I am stuck i want it to go through each row of textboxes row by row and read in the values input by the user.would some sort of inner loop again work...or is there a much easier way to do this...any help is much appreciated :biggrin:
Yeah, this is a frustration w/ VB.NET, after such things (called "control arrays") that were so easy in VB6 got tossed out in VB.NET

There ARE ways to create control arrays in VB.NET but it's quite ugly. I suggest a search on one of the VB.NET forums. The details are just too messy for me to want to go into here in a post.
 
  • Like
Likes   Reactions: Greg Bernhardt

Similar threads

  • · Replies 4 ·
Replies
4
Views
12K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 10 ·
Replies
10
Views
26K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
9
Views
2K