-
Nov 24th, 2004, 05:54 PM
#1
Thread Starter
Lively Member
Easier way?(Resolved)
Is there an easier way to do this?
VB Code:
Private Sub Form_Load()
Check0.Visible = False
Check2.Visible = False
Check3.Visible = False
Check4.Visible = False
Check5.Visible = False
Check6.Visible = False
Check7.Visible = False
Check8.Visible = False
Check9.Visible = False
Check10.Visible = False
Check11.Visible = False
Check12.Visible = False
Check13.Visible = False
Check14.Visible = False
Check15.Visible = False
Check16.Visible = False
Check17.Visible = False
Check18.Visible = False
Check19.Visible = False
Check20.Visible = False
Check21.Visible = False
Check22.Visible = False
Check23.Visible = False
Check24.Visible = False
Check25.Visible = False
Check26.Visible = False
End Sub
Thanks, Dub
Last edited by dubbemiah; Nov 25th, 2004 at 09:38 AM.
---------------------------------
Dubbemiah
"Simply, a beginner."
-
Nov 24th, 2004, 05:59 PM
#2
Addicted Member
It would've been easier for you to make an array of checkboxes. Put a single checkbox on the form, copy it, and select the array option VB gives you when you try to paste. Then just paste as much as you want...and this would be your code:
VB Code:
Dim i As Integer
For i = 0 to Check.Count - 1
Check.Visible = True
Next
-
Nov 24th, 2004, 07:34 PM
#3
It's actually still easy (but making the effort to create a control array is better in the long run).
VB Code:
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is CheckBox Then
ctl.Visible = False
End If
Next
-
Nov 24th, 2004, 09:06 PM
#4
Software Eng.
Here's another method
Code:
For i = 1 To 26
Me("Check" & i).Visible = False
Next i
-
Nov 24th, 2004, 09:36 PM
#5
Originally posted by Megatron
Here's another method
Code:
For i = 1 To 26
Me("Check" & i).Visible = False
Next i
Very nice.
-
Nov 24th, 2004, 09:42 PM
#6
Lively Member
Pretty cool learn something everyday.
Never knew you can do Me("NameofControl")
That could come have come pretty handy for me in the past.
-
Nov 25th, 2004, 06:28 AM
#7
Thread Starter
Lively Member
It's just not working for me. It always says "Control not found" My textbox arrays are as follows:
Text(0), Text(1), Text(2), Text(3), etc ending at Text(26)
code:
VB Code:
Private Sub Form_Load()
For i = 0 To 26
Me("Text" & i).Visible = False
Next i
Have also tried this
VB Code:
Private Sub Form_Load()
For i = 0 To 26
Me("Text(" & i & ")").Visible = False
Next i
Stuck.. again
---------------------------------
Dubbemiah
"Simply, a beginner."
-
Nov 25th, 2004, 06:47 AM
#8
Fanatic Member
If your text boxes are in an array then you simply need:
VB Code:
For i = 0 To 26
Text(i).Visible = False
Next i
-
Nov 25th, 2004, 07:02 AM
#9
Originally posted by dubbemiah
It's just not working for me. It always says "Control not found" My textbox arrays are as follows:
Text(0), Text(1), Text(2), Text(3), etc ending at Text(26)
code:
VB Code:
Private Sub Form_Load()
For i = 0 To 26
Me("Text" & i).Visible = False
Next i
Have also tried this
VB Code:
Private Sub Form_Load()
For i = 0 To 26
Me("Text(" & i & ")").Visible = False
Next i
Stuck.. again
The Code Me("Text" & i).Visible = false is for when you have textboxes called:
Text1
Text2
etc
It won't work with control arrays
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|