Click here to Skip to main content
14,545,210 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi For All
I Want Disable All TextBox in my form using for each command such as
for each control ontrol in me.controls
    if control.gettype is gettype textbox then
         control.enable=false
    end if
next

But I have written mistake code please help me
thanks
Posted
Updated 17-May-20 22:14pm
v2
Rate this:
Please Sign up or sign in to vote.

Solution 1

Try:
For Each c As Control In Controls
    Dim t As TextBox = TryCast(c, TextBox)
    If t IsNot Nothing Then
        t.Enabled = False
    End If
Next
   
Comments
   
Sure, a 5.
--SA
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try
for each control ontrol in me.controls
    if ontrol.gettype is gettype textbox then
         ontrol.enable=false
    end if
next
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

There you go
For Each ctl As Control in Me.Controls 
 If TypeOf(ctl) Is TextBox Then 
    ctl.Enabled = False
 End If 
Next 
   
Comments
Richard MacCutchan 18-May-20 6:59am
   
Copying other people's code from eight years ago is not really a valid solution.
codejet 19-May-20 10:43am
   
I came across that code in a training kit for MCSD (VB 6.0 ) when I was still a student in 2006. I am not claiming to be the originator of the code. So because I am not the originator of the code that disqualifies it as a valid solution?
Richard MacCutchan 19-May-20 10:59am
   
The question was solved eight years ago. And it looks like you just copied an existing solution and posted it as your own. But either way, please stick to current open questions, do not resurrect ones that are long inactive.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100