Help in converting to VB.NET

G

Guest

Hi All,
Can anybody help in converting the code below to VB.NEt thanks.
I need the loop converted..
thanks

Private Sub expandCollapseAllTreeviewNodes(ByVal nodes As
TreeNodeCollection, ByVal expand As Boolean)
Dim node As TreeNode
'Loop through each node of the collection and expand it.
For Each node In nodes
if(expand)
{
node.Expanded = true;
expandCollapseAllTreeviewNodes(node.Nodes, expand)

}
else

{
node.Expanded = true;
expandCollapseAllTreeviewNodes(node.Nodes, expand)

}


Next
 
K

Karl

The code below is like 80% in VB.Net..and the FOR loop is converted.....

Private Sub expandCollapseAllTreeviewNodes(ByVal nodes As
TreeNodeCollection, ByVal expand As Boolean)
For Each node As TreeNode In nodes
If expand Then
node.Expanded = True
expandCollapseAllTreeviewNodes(node.Nodes, expand)
Else
node.Expanded = True
expandCollapseAllTreeviewNodes(node.Nodes, expand)
End If
Next
End Sub


Karl
 
S

Scott M.

Private Sub expandCollapseAllTreeviewNodes(ByVal nodes As
TreeNodeCollection, ByVal expand As Boolean)
Dim node As TreeNode
'Loop through each node of the collection and expand it.
For Each node In nodes
If expand Then
node.Expanded = true
expandCollapseAllTreeviewNodes(node.Nodes, expand)
Else
node.Expanded = true
expandCollapseAllTreeviewNodes(node.Nodes, expand)
End If
Next
End Sub
 
C

Cowboy \(Gregory A. Beamer\)

The majority of what you have shown can be converted simply by removing the
semicolons. The IF needs a Then at the end of the line and you need to turn
the final } into an End If.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
 
S

Scott M.

For Each node As TreeNode In nodes....

Should be: For Each node In nodes

since "nodes" is already declared as TreeNodeCollection
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top