I've built an application out of Visual Basic with a login screen and a form. The login screen authenticates with Active Directory. After user authentication, the form loads. On form load, I would like to check to see if the authenticated user is in one of four particular Active Directory security groups. Depending on which group the authenticated user is in will depend on which buttons on the form are enabled. I've got the active directory user authentication to work for logging into the program and loading the form, but the specific code used to verifying which group the user is in does not work. Below is my code for form load.
Private Sub form_main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
button_main_pimam.Enabled = False
button_main_pimpm.Enabled = False
button_main_eim.Enabled = False
button_main_achmanager.Enabled = False
button_main_mobiliti.Enabled = False
button_main_checkfree.Enabled = False
button_main_rcm.Enabled = False
button_main_mis.Enabled = False
button_main_colson.Enabled = False
If My.User.IsInRole("domain.local\Fiserv Processing - Electronic Banking") Then
button_main_achmanager.Enabled = True
button_main_pimam.Enabled = True
button_main_pimpm.Enabled = True
button_main_eim.Enabled = True
button_main_colson.Enabled = True
button_main_colson.Enabled = True
ElseIf My.User.IsInRole("domain.local\Fiserv Processing - Operations") Then
button_main_achmanager.Enabled = True
button_main_mobiliti.Enabled = True
button_main_checkfree.Enabled = True
button_main_rcm.Enabled = True
button_main_colson.Enabled = True
ElseIf My.User.IsInRole("domain.local\Fiserv Processing - Loan Operations") Then
button_main_pimam.Enabled = True
button_main_pimpm.Enabled = True
button_main_eim.Enabled = True
button_main_achmanager.Enabled = True
button_main_mobiliti.Enabled = True
button_main_checkfree.Enabled = True
button_main_rcm.Enabled = True
button_main_mis.Enabled = True
ElseIf My.User.IsInRole("domain.local\Fiserv Processing - MIS") Then
button_main_pimam.Enabled = True
button_main_pimpm.Enabled = True
button_main_eim.Enabled = True
button_main_achmanager.Enabled = True
button_main_mobiliti.Enabled = True
button_main_checkfree.Enabled = True
button_main_rcm.Enabled = True
button_main_mis.Enabled = True
button_main_colson.Enabled = True
End If
End Sub
Regardless of which group the authenticated user is in, all the buttons are enabled for use. What am I doing wrong?
Try this approach. In your case, i would cache the array of groups that user belongs to when user authenticates, and then check whenever you need in your app.
Function IsInGroup(UserName As String, groupName As String) As Boolean
Dim vUsuario As New NTAccount(UserName)
Dim sid As SecurityIdentifier = vUsuario.Translate(GetType(SecurityIdentifier))
Using vRootDSE As New DirectoryEntry("LDAP://rootDSE")
Using vSearcher As New DirectorySearcher(New DirectoryEntry("LDAP://" + CStr(vRootDSE.Properties("defaultNamingContext")(0))), "(objectSID=" & sid.ToString() & ")", New String() {"memberOf"}, SearchScope.Subtree)
Dim src As SearchResultCollection = vSearcher.FindAll()
Dim memberOf As ResultPropertyValueCollection = src(0).Properties("memberOf")
For i As Integer = 0 To memberOf.Count - 1
'Debug.Print(memberOf(i).ToString())
' I don't really like this approach, but it's quick to write ;)
If memberOf(i).ToString().Contains("=" & groupName & ",") Then
Return True
End If
Next
End Using
End Using
Return False
End Function
Related
Brand new to coding junk in VBA for Microsoft Word. I have a table with 12 rows and I want to place a standard content control checkbox next to each row, and when any given checkbox is checked, the other rows disappear.
Currently I've had good luck at this with purely text, but trying to bookmark to hide an entire row of a table only seems to work for the very first checkbox. (Sorry if my code is more complicated than it needs to be. I also skipped pasting all of the code since the other 10 lines are the same, so the final 12 End Ifs are necessary):
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim cc As ContentControl
For Each cc In ActiveDocument.ContentControls
If cc.Title = "impact" Then
If cc.Checked = True Then
ActiveDocument.Bookmarks("bfganalytical").Range.Font.Hidden = True
ActiveDocument.Bookmarks("EA").Range.Font.Hidden = True
ActiveDocument.Bookmarks("fascia1").Range.Font.Hidden = True
ActiveDocument.Bookmarks("fascia2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("grille1").Range.Font.Hidden = True
ActiveDocument.Bookmarks("grille2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("shutter1").Range.Font.Hidden = True
ActiveDocument.Bookmarks("shutter2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("liner").Range.Font.Hidden = True
ActiveDocument.Bookmarks("license").Range.Font.Hidden = True
ActiveDocument.Bookmarks("lamp1").Range.Font.Hidden = True
ActiveDocument.Bookmarks("lamp2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("blank").Range.Font.Hidden = True
ActiveDocument.Bookmarks("impact").Range.Font.Hidden = False
ActiveDocument.Bookmarks("beamanalytical").Range.Font.Hidden = False
Else: ActiveDocument.Bookmarks("impact").Range.Font.Hidden = False
ActiveDocument.Bookmarks("bfganalytical").Range.Font.Hidden = False
ActiveDocument.Bookmarks("EA").Range.Font.Hidden = False
ActiveDocument.Bookmarks("fascia1").Range.Font.Hidden = False
ActiveDocument.Bookmarks("fascia2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("grille1").Range.Font.Hidden = False
ActiveDocument.Bookmarks("grille2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("shutter1").Range.Font.Hidden = False
ActiveDocument.Bookmarks("shutter2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("liner").Range.Font.Hidden = False
ActiveDocument.Bookmarks("license").Range.Font.Hidden = False
ActiveDocument.Bookmarks("lamp1").Range.Font.Hidden = False
ActiveDocument.Bookmarks("lamp2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("beamanalytical").Range.Font.Hidden = False
ActiveDocument.Bookmarks("blank").Range.Font.Hidden = False
End If
Exit Sub
Else: If cc.Title = "license" Then
If cc.Checked = True Then
ActiveDocument.Bookmarks("beamanalytical").Range.Font.Hidden = True
ActiveDocument.Bookmarks("impact").Range.Font.Hidden = True
ActiveDocument.Bookmarks("fascia1").Range.Font.Hidden = True
ActiveDocument.Bookmarks("fascia2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("grille1").Range.Font.Hidden = True
ActiveDocument.Bookmarks("grille2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("shutter1").Range.Font.Hidden = True
ActiveDocument.Bookmarks("shutter2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("liner").Range.Font.Hidden = True
ActiveDocument.Bookmarks("license").Range.Font.Hidden = False
ActiveDocument.Bookmarks("lamp1").Range.Font.Hidden = True
ActiveDocument.Bookmarks("lamp2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("blank2").Range.Font.Hidden = True
ActiveDocument.Bookmarks("blank3").Range.Font.Hidden = True
ActiveDocument.Bookmarks("EA").Range.Font.Hidden = True
ActiveDocument.Bookmarks("bfganalytical").Range.Font.Hidden = False
Else: ActiveDocument.Bookmarks("impact").Range.Font.Hidden = False
ActiveDocument.Bookmarks("bfganalytical").Range.Font.Hidden = False
ActiveDocument.Bookmarks("EA").Range.Font.Hidden = False
ActiveDocument.Bookmarks("fascia1").Range.Font.Hidden = False
ActiveDocument.Bookmarks("fascia2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("grille1").Range.Font.Hidden = False
ActiveDocument.Bookmarks("grille2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("shutter1").Range.Font.Hidden = False
ActiveDocument.Bookmarks("shutter2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("liner").Range.Font.Hidden = False
ActiveDocument.Bookmarks("license").Range.Font.Hidden = False
ActiveDocument.Bookmarks("lamp1").Range.Font.Hidden = False
ActiveDocument.Bookmarks("lamp2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("beamanalytical").Range.Font.Hidden = False
ActiveDocument.Bookmarks("blank2").Range.Font.Hidden = False
ActiveDocument.Bookmarks("blank3").Range.Font.Hidden = False
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next
End Sub
Assuming that the content control Title is the same as the bookmark name you can try this simplified version of your code.
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim cc As ContentControl
For Each cc In ActiveDocument.ContentControls
If ActiveDocument.Bookmarks.Exists(cc.Title) Then
ActiveDocument.Bookmarks(cc.Title).Range.Font.Hidden = cc.Checked
End If
Next cc
End Sub
EDIT:
The issue you have with your original code is that it will only allow one row to be hidden.
To make your solution work you need to query the checked status of the corresponding content control for each bookmark. Your best option to achieve that is to ensure that the bookmark name matches either cc.Title or cc.Tag, otherwise you are back to complex and unwieldy code.
You actually don't need anything more complicated than:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
With CCtrl
If .Range.Information(wdWithInTable) = True Then
If .Checked = True Then
.Range.Tables(1).Range.Font.Hidden = True
.Range.Rows(1).Range.Font.Hidden = False
Else
.Range.Tables(1).Range.Font.Hidden = False
End If
End If
End With
End Sub
Looping through all the content controls is quite unnecessary. You don't even need any titles or bookmarks.
not sure if there is an easier way to do this but I have a LOT of buttons on a form. Different ones are visible for different functions.
Is there a way to have something like this have an easier way to change their visibility without having each button coded to go False/True?
For simplicity sake, I created a quick app to handle the visibility but I want to hide the others when one set of buttons is visible. So if I select Row 1, it will make Visibility FALSE on Row 2 and 3.
Am I stuck with this or is there an easier way/more efficient way? THANKS IN ADVANCE!
Public Class Form1
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedItem.ToString = "Button Row 1" Then
Button1.Visible = True
Button2.Visible = True
Button3.Visible = True
Button4.Visible = True
Button5.Visible = True
Button6.Visible = True
Button7.Visible = True
Button8.Visible = True
Button9.Visible = True
Button10.Visible = True
Button11.Visible = False
Button12.Visible = False
Button13.Visible = False
Button14.Visible = False
Button15.Visible = False
Button16.Visible = False
Button17.Visible = False
Button18.Visible = False
Button19.Visible = False
Button20.Visible = False
Button21.Visible = False
Button22.Visible = False
Button23.Visible = False
Button24.Visible = False
Button25.Visible = False
Button26.Visible = False
Button27.Visible = False
Button28.Visible = False
Button29.Visible = False
Button30.Visible = False
ElseIf ComboBox1.SelectedItem.ToString = "Button Row 2" Then
Button1.Visible = False
Button2.Visible = False
Button3.Visible = False
Button4.Visible = False
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
Button8.Visible = False
Button9.Visible = False
Button10.Visible = False
Button11.Visible = True
Button12.Visible = True
Button13.Visible = True
Button14.Visible = True
Button15.Visible = True
Button16.Visible = True
Button17.Visible = True
Button18.Visible = True
Button19.Visible = True
Button20.Visible = True
Button21.Visible = False
Button22.Visible = False
Button23.Visible = False
Button24.Visible = False
Button25.Visible = False
Button26.Visible = False
Button27.Visible = False
Button28.Visible = False
Button29.Visible = False
Button30.Visible = False
ElseIf ComboBox1.SelectedItem.ToString = "Button Row 3" Then
Button1.Visible = False
Button2.Visible = False
Button3.Visible = False
Button4.Visible = False
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
Button8.Visible = False
Button9.Visible = False
Button10.Visible = False
Button11.Visible = False
Button12.Visible = False
Button13.Visible = False
Button14.Visible = False
Button15.Visible = False
Button16.Visible = False
Button17.Visible = False
Button18.Visible = False
Button19.Visible = False
Button20.Visible = False
Button21.Visible = True
Button22.Visible = True
Button23.Visible = True
Button24.Visible = True
Button25.Visible = True
Button26.Visible = True
Button27.Visible = True
Button28.Visible = True
Button29.Visible = True
Button30.Visible = True
End If
End Sub
End Class
Set the tag property of the buttons. You can do it in the properties window. I just show it in code to illustrate the point
Button1.Tag = "Button Row 1"
Then you can do
Dim selectedRow = ComboBox1.SelectedItem.ToString()
For Each c As Control In Controls
If (TypeOf c Is Button) Then
c.Visible = selectedRow.Equals(c.Tag)
End If
Next
Note that this automatically shows the buttons of the selected row and hides the others.
If this affects too many buttons, you can also check if the Tag is not Nothing instead of testing if it is a button.
You could use a for loop and keep track of which textbox is in which row, could put the row in the name, tag, use a custom property, etc.
You could put each row in a groupbox and just change the visibility of the group.
You could make a list of Buttons for each row, add the buttons, and loop through those lists.
Winforms support data binding.
' In form constructor
public Sub New()
InitializeComponent()
cmbEnableButtons.DataSource = New List(Of string) From
{
"Nothing",
"Button Row 1",
"Button row 2"
}
button1.Tag = "Button Row 1"
button2.Tag = "Button Row 1"
button3.Tag = "Button Row 2"
button4.Tag = "Button Row 2"
button1.DataBindings.Add(CreateBindingForVisible())
button2.DataBindings.Add(CreateBindingForVisible())
button3.DataBindings.Add(CreateBindingForVisible())
button4.DataBindings.Add(CreateBindingForVisible())
}
Private Function CreateBindingForVisible() As Binding
Dim buttonBinding =
New Binding("Visible",
cmbEnableButtons,
"SelectedValue",
true,
DataSourceUpdateMode.OnPropertyChanged)
' Every time selected value of combobox changed
' this event handler convert string to "visible" boolean
AddHandler buttonBinding.Format, AddressOf ButtonBinding_Format
return buttonBinding;
End Sub
Private Sub ButtonBinding_Format(object sender, ConvertEventArgs e)
Dim binding = DirectCast(sender, Binding)
Dim button = DirectCast(binding.Control, Button)
e.Value = Equals(button.Tag, e.Value)
End Sub
With data binding you can configure every button separately from each other, while having common logic in one place.
How to make the second event start after the first one.
Below is a code that copies files from 2 different paths set by the user for me. On the other hand, it wants to make the first copy from another path before it goes to the next one.
Public Sub StartCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartCopy.Click
' Reset variables
_stopped = False
' Create the FileCopy class which will initiate the threads
CopyFiles = New FileCopy
CopyFiles.FromPath = My.Settings.pathmemfrom1
CopyFiles.ToPath = My.Settings.pathmemto1
' Initiate the copy, count from the FileCopy class
CopyFiles.StartCopy()
WorkingBar.Minimum = 0
WorkingBar.Maximum = 100
WorkingLabel.Visible = True
WorkingBar.Visible = True
' Reset form controls
setting.Panel.Enabled = False
StopCopy.Enabled = True
ViewLog.Enabled = True
CopyFiles.Dispose()
'Reset veriables
_stopped = False
' Create the FileCopy class which will initiate the threads
CopyFiles2 = New FileCopy
CopyFiles2.FromPath = My.Settings.pathmemfrom2
CopyFiles2.ToPath = My.Settings.pathmemto2
CopyFiles2.StartCopy()
WorkingBar.Minimum = 0
WorkingBar.Maximum = 100
WorkingLabel.Visible = True
WorkingBar.Visible = True
' Reset form controls
setting.Panel.Enabled = False
StopCopy.Enabled = True
ViewLog.Enabled = True
CopyFiles2.Dispose()
'Reset veriables
_stopped = False
I am trying something that I don't know if it is possible to do.
When I press a button, the property .visible of many labels must change, and I am doing that using this:
Private Sub AlakranPositionsButton_Click(sender As Object, e As EventArgs) Handles AlakranPositionsButton.Click
If AlakranLabel.Visible = False Then
Label4.Visible = True
Label5.Visible = True
AlakranLabel.Visible = True
Alakran1Label.Visible = True
Alakran2Label.Visible = True
Alakran3Label.Visible = True
Alakran4Label.Visible = True
Alakran5Label.Visible = True
Alakran6Label.Visible = True
Alakran7Label.Visible = True
Alakran8Label.Visible = True
Alakran9Label.Visible = True
Alakran10Label.Visible = True
Alakran1YTextBox.Visible = True
Alakran2YTextBox.Visible = True
Alakran3YTextBox.Visible = True
Alakran4YTextBox.Visible = True
Alakran5YTextBox.Visible = True
Alakran6YTextBox.Visible = True
Alakran7YTextBox.Visible = True
Alakran8YTextBox.Visible = True
Alakran9YTextBox.Visible = True
Alakran10YTextBox.Visible = True
Alakran1XTextBox.Visible = True
Alakran2XTextBox.Visible = True
Alakran3XTextBox.Visible = True
Alakran4XTextBox.Visible = True
Alakran5XTextBox.Visible = True
Alakran6XTextBox.Visible = True
Alakran7XTextBox.Visible = True
Alakran8XTextBox.Visible = True
Alakran9XTextBox.Visible = True
Alakran10XTextBox.Visible = True
Else
Label4.Visible = False
Label5.Visible = False
AlakranLabel.Visible = False
Alakran1Label.Visible = False
Alakran2Label.Visible = False
Alakran3Label.Visible = False
Alakran4Label.Visible = False
Alakran5Label.Visible = False
Alakran6Label.Visible = False
Alakran7Label.Visible = False
Alakran8Label.Visible = False
Alakran9Label.Visible = False
Alakran10Label.Visible = False
Alakran1YTextBox.Visible = False
Alakran2YTextBox.Visible = False
Alakran3YTextBox.Visible = False
Alakran4YTextBox.Visible = False
Alakran5YTextBox.Visible = False
Alakran6YTextBox.Visible = False
Alakran7YTextBox.Visible = False
Alakran8YTextBox.Visible = False
Alakran9YTextBox.Visible = False
Alakran10YTextBox.Visible = False
Alakran1XTextBox.Visible = False
Alakran2XTextBox.Visible = False
Alakran3XTextBox.Visible = False
Alakran4XTextBox.Visible = False
Alakran5XTextBox.Visible = False
Alakran6XTextBox.Visible = False
Alakran7XTextBox.Visible = False
Alakran8XTextBox.Visible = False
Alakran9XTextBox.Visible = False
Alakran10XTextBox.Visible = False
End If
I think that there must be a way to do something like this:
If AlakranLabel.Visible = False Then
For i As Integer = 0 To 20
Label(i).visible = False
Next
Else
For i As Integer = 0 To 20
Label(i).visible = True
Next
End If
Someone knows how to do this? I am not able to see how to do it..
Thanks!
Solution
Declaration of the lists:
Dim listObjectiveLabels As List(Of Label) = New List(Of Label)
Dim listObjectiveTextBox As List(Of TextBox) = New List(Of TextBox)
Add each label and textbox in a list:
listAlakranLabels.Add(AlakranLabel)
listAlakranLabels.Add(Alakran1Label)
listAlakranLabels.Add(Alakran2Label)
listAlakranLabels.Add(Alakran3Label)
listAlakranLabels.Add(Alakran4Label)
listAlakranLabels.Add(Alakran5Label)
listAlakranLabels.Add(Alakran6Label)
listAlakranLabels.Add(Alakran7Label)
listAlakranLabels.Add(Alakran8Label)
listAlakranLabels.Add(Alakran9Label)
listAlakranLabels.Add(Alakran10Label)
listAlakranTextBox.Add(Alakran1YTextBox)
listAlakranTextBox.Add(Alakran2YTextBox)
listAlakranTextBox.Add(Alakran3YTextBox)
listAlakranTextBox.Add(Alakran4YTextBox)
listAlakranTextBox.Add(Alakran5YTextBox)
listAlakranTextBox.Add(Alakran6YTextBox)
listAlakranTextBox.Add(Alakran7YTextBox)
listAlakranTextBox.Add(Alakran8YTextBox)
listAlakranTextBox.Add(Alakran9YTextBox)
listAlakranTextBox.Add(Alakran10YTextBox)
listAlakranTextBox.Add(Alakran1XTextBox)
listAlakranTextBox.Add(Alakran2XTextBox)
listAlakranTextBox.Add(Alakran3XTextBox)
listAlakranTextBox.Add(Alakran4XTextBox)
listAlakranTextBox.Add(Alakran5XTextBox)
listAlakranTextBox.Add(Alakran6XTextBox)
listAlakranTextBox.Add(Alakran7XTextBox)
listAlakranTextBox.Add(Alakran8XTextBox)
listAlakranTextBox.Add(Alakran9XTextBox)
listAlakranTextBox.Add(Alakran10XTextBox)
Use for each sentence:
For Each l As Label In listAlakranLabels
l.Visible = True
Next
For Each l As TextBox In listAlakranTextBox
l.Visible = True
Next
You've got 2 options:
1.- Adding your labels to a List<Label> and the use a For Each to set their Visible property:
Dim allLabels As List(Of Label) = New List(Of Label);
allLabels.Add(Label4)
allLabels.Add(Label5)
allLabels.Add(AlakranLabel)
...
For Each l As Label In allLabels
l.Visible = True
Next
2.- If you want to show/hide all the labels inside a container, you can For Each the container Controls Collection, like this:
For Each l As Label In Me.Controls.OfType(Of Label)
l.Visible = True
Next
EDIT
You've got another option, using the Find method of the Controls collection:
For i As Integer = 1 To 10
Me.Controls.Find("Alakran" & i & "Label", False).FirstOrDefault().Visible = True
Next
This would set all labels from Alakran1Label to Alakran10Label visibility to True
You can iterate on all instances of the Label or Textbox in your form (or container) by :
First declaring a control variable to handle each object in your Container collection
Determine if the current control is a label
setting their visibility to false.
Dim lbl_holder as Control
For each lbl_holder in Me.Controls
If typeof lbl_holder is Label or Typeof lbl_holder is Textbox then
lbl_holder.Visible = False
End If
Next
Hye there, I new with vba here.
I want to use checkboxes to link with the series collections of a chart. I put the check boxes in a sheet which contain the chart altogether. I have a lot of checkboxes here to be assigned to "true" value.
Private Sub Controls_Initialize()
'Make default for checkboxes
CheckBox1.Value = True
CheckBox2.Value = True
CheckBox3.Value = True
CheckBox4.Value = True
CheckBox5.Value = True
CheckBox6.Value = True
CheckBox7.Value = True
CheckBox8.Value = True
CheckBox9.Value = True
CheckBox10.Value = True
CheckBox11.Value = True
CheckBox12.Value = True
CheckBox13.Value = True
CheckBox14.Value = True
CheckBox15.Value = True
CheckBox16.Value = True
CheckBox17.Value = True
CheckBox18.Value = True
CheckBox19.Value = True
CheckBox20.Value = True
CheckBox21.Value = True
CheckBox22.Value = True
CheckBox23.Value = True
CheckBox24.Value = True
End Sub
I have tried this code but can't
For i = 1 to 24
Controls("CheckBox" & i).Value = True
Next i
The questions are
1. Is there any other code that can make it simple?
2. How to link the check boxes with the series collection in the activechart? Example, if the checkbox return value false, the series collection will be deleted/hide(perhaps?). And when it returns value true, the series collection of the same data will be added back in the chart. I would like to make the chart interactive.
If there is any reference that I can reviewed, do tell me.
Thanks in advance.
Regards.
Alright, so assuming from what you've given, I'd think the problem is that the interpreter doesn't know i is an integer.
To fix this, we can implement something along the lines of Dim i As Integer to implement i as an integer.
We could try this:
Dim i As Integer
For i = 1 to 24
Controls("CheckBox" & i).Value = True
Next i