|
-
Sep 11th, 2000, 04:34 AM
#1
Thread Starter
Frenzied Member
I know this is an easy one.
Please tell me what the right code is here.
For each (checkbox) in (form)
(checkbox).value = 0
Just to "turn off" all the checkboxes at once.
I know it's either this or a with statement but I don't remember it.
If you do, please post.
Thanks.
wengang
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Sep 11th, 2000, 04:41 AM
#2
Conquistador
you could put all the check boxes into a control array and make it very easy:
Code:
For i = 0 To Check1.Count - 1
If Check1(i).Value = 1 Then
Check1(i).Value = 0
Else
Check1(i).Value = 1
End If
Next i
this alternates the status of each checkbox.
-
Sep 11th, 2000, 04:45 AM
#3
Thread Starter
Frenzied Member
Thanks
but the code i'm looking for is along these lines
Dim fCheckbox As Checkbox
For Each fCheckbox In frmMain
fCheckbox.Value= 0
Next
This code doesn't work obviously, so does anybody know how to repair it?
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Sep 11th, 2000, 04:49 AM
#4
Conquistador
this does it without having an array
Code:
For i = 0 To Form1.Controls.Count - 1
If TypeOf Form1.Controls(i) Is CheckBox Then
If Form1.Controls(i).Value = 0 Then
Form1.Controls(i).Value = 1
Else
Form1.Controls(i).Value = 0
End If
End If
Next i
it alternates the value of every checkbox on the form
-
Sep 11th, 2000, 04:54 AM
#5
Conquistador
yet another way:
Code:
On Error GoTo ErrHandler:
For Each CheckBox In Me.Controls
If CheckBox.Value = 0 Then
CheckBox.Value = 1
Else
CheckBox.Value = 0
End If
Next CheckBox
ErrHandler:
i think this was along the lines you were thinking, but all of my examples work 
so, how's this one?
-
Sep 12th, 2000, 04:42 AM
#6
Thread Starter
Frenzied Member
Thanks a lot David. I never lost confidence in you.
But, it was the second example that worked for me.
The third one (for whatever reason) sends out the error 'Object doesn't support this property or method'
Anyway, i appreciate it. That will make my "Reset" key a lot faster to code in the future.
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Sep 15th, 2000, 02:13 AM
#7
Conquistador
well, i got there in the end,
i don't know why the third one didn't work, it worked for me
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
|