Craig_Muckleston
asked on
Synatx Error Instantiating a New Class
I am converting some C# code to VB. I create the class below:
Public Class FileNode
Inherits TreeNode
Private _fileInfo As FileInfo
Private _directoryNode As DirectoryNode
Public Sub New(ByVal directoryNode As DirectoryNode, ByVal fileInfo As FileInfo)
MyBase.New(fileInfo.Name)
Me._directoryNode = directoryNode
Me._fileInfo = fileInfo
Me.ImageIndex = 1 'DirectCast(_directoryNode .TreeView, FileSystemTreeView).GetIco nImageInde x(_fileInf o.FullName )
Me.SelectedImageIndex = Me.ImageIndex
_directoryNode.Nodes.Add(M e)
End Sub
End Class
I now call this class from a function (basically building up nodes in a treeview):
Public Sub LoadFiles()
For Each file As FileInfo In _directoryInfo.GetFiles()
New FileNode(Me, file)
Next
End Sub
However, I get a syntax error on the word New (New FileNode(Me, file)). Any ideas how to get around this?
Public Class FileNode
Inherits TreeNode
Private _fileInfo As FileInfo
Private _directoryNode As DirectoryNode
Public Sub New(ByVal directoryNode As DirectoryNode, ByVal fileInfo As FileInfo)
MyBase.New(fileInfo.Name)
Me._directoryNode = directoryNode
Me._fileInfo = fileInfo
Me.ImageIndex = 1 'DirectCast(_directoryNode
Me.SelectedImageIndex = Me.ImageIndex
_directoryNode.Nodes.Add(M
End Sub
End Class
I now call this class from a function (basically building up nodes in a treeview):
Public Sub LoadFiles()
For Each file As FileInfo In _directoryInfo.GetFiles()
New FileNode(Me, file)
Next
End Sub
However, I get a syntax error on the word New (New FileNode(Me, file)). Any ideas how to get around this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.