
Sub ControlloCheckBox() For i = 0 To i = 10 If CheckBox + i.Value = True Then out i = i^2 Else: out i = 0 End If Next i End Sub |
Me.Controls.Add "Forms.CommandButton.1", "Test", True
Private Sub CheckBox5_Click() If CheckBox5.Value = True Then out8 = 128 Else: out8 = 0 End If End Sub Private Sub CheckBox6_Click() If CheckBox6.Value = True Then out1 = 1 Else: out1 = 0 End If End Sub Private Sub CheckBox7_Click() If CheckBox7.Value = True Then out2 = 2 Else: out2 = 0 End If End Sub Private Sub CheckBox8_Click() If CheckBox8.Value = True Then out3 = 4 Else: out3 = 0 End If End Sub Private Sub CheckBox38_Click() If CheckBox38.Value = True Then out14 = 2 ^ 10 Else: out14 = 0 End If End Sub Private Sub CheckBox39_Click() If CheckBox39.Value = True Then out13 = 2 ^ 10 Else: out13 = 0 End If End Sub Private Sub CheckBox40_Click() If CheckBox40.Value = True Then out15 = 2 ^ 10 Else: out15 = 0 End If End Sub Private Sub CheckBox41_Click() If CheckBox41.Value = True Then out16 = 2 ^ 10 Else: out16 = 0 End If End Sub Private Sub CheckBox42_Click() If CheckBox42.Value = True Then out9 = 2 ^ 9 Else: out9 = 0 End If End Sub Private Sub CheckBox43_Click() If CheckBox43.Value = True Then out10 = 2 ^ 10 MsgBox (out10) Else: out10 = 0 End If End Sub Private Sub CheckBox44_Click() If CheckBox44.Value = True Then out11 = 2 ^ 11 Else: out11 = 0 End If End Sub Private Sub CheckBox45_Click() If CheckBox45.Value = True Then out12 = 2 ^ 12 Else: out12 = 0 End If End Sub |
userform code
Sub MyCountingRoutine
'count how many checkboxes are selected, and show apt message
Dim intLoop as Integer
Dim intCount as Integer
intCount = 0
For intLoop = 0 to 31
If chkArray(intLoop).Value = vbChecked Then 'not sure if this line is correct for VBA!
intCount = intCount + 1
End If
Next intLoop
LBL_message.Caption = "text" & intCount & "text"
If intCount Mod 2 = 0 Then
LBL_message.Caption = LBL_message.Caption & "OK"
Else
LBL_message.Caption = LBL_message.Caption & "not right!"
End If
End Sub
|
Dim nCB As Integer
For nCB = 1 To 20
Me.Controls("Combobox" & nCB).AddItem xxx 'è solo un esempio
Next nCB
|
