View Single Post
 
Old 04-26-2013, 10:01 AM
ecka333 ecka333 is offline
Newcomer
 
Join Date: Apr 2013
Posts: 1
Default Controls.Find: how to use?

I am doing my four channel timer for aquarium project. I am using Visual basic.Net Express 2010. Today i faced one ugly problem in this line:

Code:
Me.Controls.Find("TextBox" & Address, True)(0).Text = "0"
Compiler shows error:
"IndexOutOfRangeException was unhandled." and
"Index was outside the bounds of the array."
As i suspect "TextBox" & Address in the parentheses causes the problem. Address variable is byte type and it can be from 1 to 48 and from 53 to 55.
Tried to use
Code:
Me.Controls.Find("TextBox" + Cstr(Address), True)(0).Text = "0"
but result is the same. Then changed text to:
Code:
Me.Controls.Find("TextBox1", True)(0).Text = "0"
and it worked. But this is not a way out to me.
Maybe somebody faced with similar problem?
Reply With Quote