J
Jacob.Bruxer
Hi,
I want to be able to append text using a For loop to each textbox in an
array of textboxes that I've created, called tBoxes(). Basically I
want to add a number of spaces to each textbox in the array. ie. If
spaces(0) = 3, I'd want to add 3 spaces (" ") to tBoxes(0), if
spaces(1) = 4, I'd want to add 4 spaces (" ") to tBoxes(1), and so
on. My code looks something like this...
Dim i as integer
Dim j as integer
Dim m as integer
' I determine value j, which is the length of each of my arrays
j = some integer
Dim tBoxes(j-1) as textbox
Dim spaces(j-1) as integer
' I determine the number of spaces and assign integer values to the
array spaces(i)
' For each textbox, I try to append a space for each integer in
spaces(i), but it doesn't work.
For i = 0 To j - 1
For m = 1 To spaces(i)
tBoxes(i).AppendText(" ")
Next
Next
When I run the code I get an error: "NullReferenceException was
unhandled" and "Object reference not set to an instance of an object."
I hope this is all clear. I'm new to programming so any suggestions or
ideas on what I'm doing wrong would be most appreciated. Thanks.
I want to be able to append text using a For loop to each textbox in an
array of textboxes that I've created, called tBoxes(). Basically I
want to add a number of spaces to each textbox in the array. ie. If
spaces(0) = 3, I'd want to add 3 spaces (" ") to tBoxes(0), if
spaces(1) = 4, I'd want to add 4 spaces (" ") to tBoxes(1), and so
on. My code looks something like this...
Dim i as integer
Dim j as integer
Dim m as integer
' I determine value j, which is the length of each of my arrays
j = some integer
Dim tBoxes(j-1) as textbox
Dim spaces(j-1) as integer
' I determine the number of spaces and assign integer values to the
array spaces(i)
' For each textbox, I try to append a space for each integer in
spaces(i), but it doesn't work.
For i = 0 To j - 1
For m = 1 To spaces(i)
tBoxes(i).AppendText(" ")
Next
Next
When I run the code I get an error: "NullReferenceException was
unhandled" and "Object reference not set to an instance of an object."
I hope this is all clear. I'm new to programming so any suggestions or
ideas on what I'm doing wrong would be most appreciated. Thanks.