wiwin21
New member
- Local time
- Today, 09:40
- Joined
- Nov 23, 2020
- Messages
- 1
Hello all!
I am new to programming, and now I am trying to have this code that will check/uncheck the children and subchildren if the parent node is checked. Also, the parent node gets checked if one of the children / subchildren is checked.
Now, the code works in my computer, but does not in another PC.
It shows the "compile error : procedure declaration does not match description of event or procedure having the same name" error. The error happens on the procedure declaration itself. I tried rewriting the exact declaration in that other computer, and then it worked! But then when I passed the file onto the original computer, it now shows the exact error.
I hope someone could help me out!
Here is the code:
I am new to programming, and now I am trying to have this code that will check/uncheck the children and subchildren if the parent node is checked. Also, the parent node gets checked if one of the children / subchildren is checked.
Now, the code works in my computer, but does not in another PC.
It shows the "compile error : procedure declaration does not match description of event or procedure having the same name" error. The error happens on the procedure declaration itself. I tried rewriting the exact declaration in that other computer, and then it worked! But then when I passed the file onto the original computer, it now shows the exact error.
I hope someone could help me out!
Here is the code:
Code:
Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)
Dim iChild, yChild As Integer
Dim nodX, nodY As Node
If Node.Children <> 0 Then
'if there are children present, then Node is a parent
Set nodX = Node.Child
For iChild = 1 To Node.Children
nodX.Checked = Node.Checked
If nodX.Children <> 0 Then
'if there are children present, then node is a child with subchildren
Set nodY = nodX.Child
For yChild = 1 To nodX.Children
nodY.Checked = nodX.Checked
Set nodY = nodY.Next
'if a subchild is checked, then nodX, which is a child, should be checked
'do this loop to check if any of the subchildren is checked, then check the child
Next
End If
'if a child is checked, then Node, which is a parent, should be checked
'do this loop to check if any of the children is checked, then check the parent
Set nodX = nodX.Next
Next
Else
If Not Node.Parent Is Nothing Then
'if the parent of the Node does exist, then it is a child
If Node.Checked Then
'check the parent and skip the loop if the current node is checked.
Node.Parent.Checked = True
Else
Node.Parent.Checked = False
'if the Node, which is a child, is unchecked, then uncheck the parent
'however, proceed with the loop below to see if other children are checked. If yes, check the parent
Set nodX = Node.Parent.Child
Do Until nodX Is Nothing
If nodX.Checked Then
'at least one other child node is checked so check the parent and exit the loop
Node.Parent.Checked = True
Exit Do
End If
Set nodX = nodX.Next
Loop
End If
End If
End If
End Sub