I am working on vb.net window application where i have to find Control in window form by string name. For that i used the following code:-
Dim lbl As New Label
Dim st As String
st = "lblFeeder" + i.ToString()
lbl = CType(Me.Controls(st), Label)
lbl.Text = dt.Rows(37)("AnaTagValue")
But when the program runs it gives a error
"Object reference not set to an instance of an object."
at the postion
"lbl.Text = dt.Rows(37)("AnaTagValue")"
When i debug it i Found "Nothing" at the position "lbl = CType(Me.Controls(st), Label)"
How can I solve this?