Re: visual basic 6 - help looping through checkboxes
- From: "Ken Halter" <Ken_Halter@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 15 Oct 2008 12:25:30 -0700
<zerbie45@xxxxxxxxx> wrote in message
news:99f43a80-651e-4252-bf4f-231a59855e5c@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
If anybody could show a very simple example of how this would be coded
I would be most grateful!
There are so many ways to approach this, it's hard to say without having
more info. Are the checkboxes part of a control array? If not, this is about
as straight forward as it gets....
'==========
Private Sub Command1_Click()
If Check1.Value = vbChecked Then
'do some work
End If
If Check2.Value = vbChecked Then
'do some work
End If
End Sub
'==========
This actually "loops" thru all controls on a form, looking for checkboxes.
If found, it does work based on the checkboxes name
'==========
Private Sub Command1_Click()
Dim cb As Control
Dim sName As String
For Each cb In Controls
If TypeOf cb Is CheckBox Then
If cb.Value = vbChecked Then
sName = cb.Name
Select Case sName
Case "Check1"
'do some work
Case "Check2"
'do some work
End Select
End If
End If
Next
End Sub
'==========
This loops thru an array (Control Array) of checkboxes and, if checked, does
the work associated with that checkbox (based on its Index in the array)
'==========
Private Sub Command1_Click()
Dim cb As CheckBox
Dim sName As String
For Each cb In Check1
If cb.Value = vbChecked Then
Select Case cb.Index
Case 0
'do some work
Case 1
'do some work
End Select
End If
Next
End Sub
'==========
--
Ken Halter
Part time groupie
.
- References:
- visual basic 6 - help looping through checkboxes
- From: zerbie45
- visual basic 6 - help looping through checkboxes
- Prev by Date: Re: Recurrence loop in VB6 - weekly portion
- Next by Date: Re: Add a context menu item to Windows Explorer (Win98) with VB6?
- Previous by thread: visual basic 6 - help looping through checkboxes
- Index(es):
Relevant Pages
|