VB Code:
option strict on
imports system
imports system.drawing
imports system.windows.forms
public class sample
inherits form
sub new()
mybase.new()
initializecomponent()
end sub
public withevents t1 as new textbox()
public withevents t2 as new textbox()
public withevents t3 as new textbox()
sub initializecomponent()
t1.setbounds(100,100,100,20)
t2.setbounds(100,125,100,20)
t3.setbounds(100,150,100,20)
me.controls.addrange(new control(){t1,t2,t3})
for each c as control in me.controls
if typeof c is textbox then
addhandler c.gotfocus, addressof t
addhandler c.leave, addressof tt
end if
next
end sub
sub t(sender as object,e as eventargs)
ctype(sender,textbox).backcolor=color.red
end sub
sub tt(sender as object,e as eventargs)
ctype(sender,textbox).backcolor=color.white
end sub
shared sub main()
application.run(new sample())
end sub
end class
i do a