既存シェープファイル フィーチャクラスの取得

Public Function fncOpenShapefile(sPath As String, sFile As String) As IFeatureClass
'    Dim sPath As String
'    sPath = "D:\Data"
'
'    Dim sFile As String
'    sFile = "Shapefile.shp"
    
    Dim pWorkspaceFactory As IWorkspaceFactory
    Set pWorkspaceFactory = New ShapefileWorkspaceFactory
    
    Dim pFeatureWorkspace As IFeatureWorkspace
    Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(sPath, Application.hWnd)
    
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeatureWorkspace.OpenFeatureClass(sFile)
    
    Set fncOpenShapefile = pFeatureClass
    
End Function