Link to home
Start Free TrialLog in
Avatar of Craig_Muckleston
Craig_MucklestonFlag for United Kingdom of Great Britain and Northern Ireland

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).GetIconImageIndex(_fileInfo.FullName)
            Me.SelectedImageIndex = Me.ImageIndex

            _directoryNode.Nodes.Add(Me)
        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
Avatar of dctuck
dctuck
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial