I would just like to add that the For loop ForumAccount uses will not visit nested controls (controls in a panel/groupbox/tabpage, whatever), as he mentioned already, whereas the Do loop used by Hack does.
Also, to both of you, isn't it better to use the following:
instead of using the TypeOf operator, and then the DirectCast function? As far as I know, both TypeOf and (obviously) DirectCast will perform a cast, so it will be cast twice, whereas the TryCast way will cast only once. If 'tb' isn't derived from a TextBox then it will be Nothing after the cast, so that is more or less equivalent to using the TypeOf operator, isn't it?Code:Dim tb As TextBox = TryCast(ctrl, TextBox) If tb IsNot Nothing Then tb.ReadOnly = IsReadOnly
I'm sure it will be a minor difference, but perhaps if you have loads and loads of textboxes..?
Am I right about this, or does it not make a difference at all?




Reply With Quote