"Brian Henry" <br**********@newsgroups.nospam> schrieb
how would you disable all text boxes on a form at once/
I thought
dim tx as textbox
for each tx in me.controls
tx.enabled = false
next
but that crashes, what do you guys suggest? thanks
Not all controls on the Form are textboxes, so whenever, within the loop, a
control is assigned to 'tx' that is not a textbox, an InvalidCastException
occurs. Instead:
dim o as object
for each o in me.controls
if typeof o is textbox then
directcast(o, textbox).enabled = false
end if
next
Note that this only processes the Textboxes directly placed on the Form, not
those eg placed on a groupbox on the Form.
--
Armin
How to quote and why:
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html