I want to use a string array as an identifier to interact with a group of textboxes in a userform.
this would mean having code like
string[] Book = new string[5];
Book[1] = "Title"; Book[2] = "Author"; ...etc
Then I could use this to obtain information from the textbox. e.g. MessageBox.Show (Userform.Book[1].Text.toString());
I don't seem to be able to find a way to convert/cast the string so I can use it to identify the TextBox in the Userform so would it be right to assume it is not possible?
IjoranPosted May 16, 2008, 3:23 AM
Looks like Form Controls are where I needed to be looking, thanks for yor help Dipal.
This goes for the hashtables as wel, cheers Ryan.
Ryan AlfordPosted May 15, 2008, 7:39 PM
Dipal ChoksiPosted May 15, 2008, 12:26 PM
Hi,
Here is a link to an article that describes how to get the reference to a control on a windows form by passing the name of the control. You can adapt this code to use the values from your string array to set the Text for the text boxes.
http://www.eggheadcafe.com/articles/20040506.asp
Hope this helps...
IjoranPosted May 15, 2008, 2:11 AM
Windows System Forms
And my guess is thats going to be the wrong answer to make me a happy camper.
Dipal ChoksiPosted May 15, 2008, 2:07 AM
IjoranPosted May 15, 2008, 1:54 AM
Yes. Exactly.
I will be reading in the string information for the array from another document. Each string will have another corresponding string with related data e.g.
Book[1] = "Title"; BookData[1] = "Dictionary";
Book[2] = "Author"; BookData[2] = "Samuel Johnson";
I will then loop through both array's and use Book[] to be the identifier for the textbox in the userform. From here I can populate the textbox with BookData[] information.
Hope that makes sense.
Dipal ChoksiPosted May 15, 2008, 12:55 AM