I've got a set of textboxes called txtTextBox1 to txtTextBox9. I want to access the text attribute of each one of these in turn and stuff it into an array dimension of the equivalent number. Something like this:
Dim i As Integer
Dim arrString(10) As Array
For i = 1 to 9
arrString(i) = txtTextBox[i].Text
Next
Now this isn't going to work, obviously, but how in .NET would I go about achieving this effect?
Cheers,
MattOne way to handle this would be to walk throught the controls collection and stuff relevant items to your array
int i=0;
foreach(Control c in frm1.Controls)
{
//check if c.ID is same as you are looking
arrString[i] = ((TextBox)c).Text;
i++;
}
Hope that helps
Kashif
0 comments:
Post a Comment