当前位置:编程学习 > VB >>

vc转换成vb

public void AddAccessDBByName() { IWorkspaceName pWorkspaceName = new WorkspaceNameClass() ; pWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory"; pWorkspaceName.PathName = @"D:\test\Ao\data\sh\MapData.mdb"; IName n = pWorkspaceName as IName ; IFeatureWorkspace Workspace = n.Open() as IFeatureWorkspace; IFeatureClass Fcls = Workspace.OpenFeatureClass ("District"); IFeatureLayer Fly = new FeatureLayerClass(); Fly.FeatureClass = Fcls; MapCtr.Map.AddLayer (Fly); MapCtr.ActiveView.Refresh(); } 转换成vb代码?? 求高手转换一下!!!
答案:public sub AddAccessDBByName() 
      dim pWorkspaceName  as IWorkspaceName  
       pWorkspaceName  =new WorkspaceNameClass() 
      '--> dim  pWorkspaceName  as new WorkspaceNameClass
     ' IWorkspaceName  pWorkspaceName = new WorkspaceNameClass() ; 
   
    pWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory"  '; 
      pWorkspaceName.PathName = "D:\test\Ao\data\sh\MapData.mdb"  '; 
      dim n as IName 
      n=pWorkspaceName 
     ' IName n = pWorkspaceName as IName ; 
      'IFeatureWorkspace Workspace = n.Open() as IFeatureWorkspace; 
       dim   Workspace as IFeatureWorkspace 
         Workspace=n.Open() 
     dim Fcls  as IFeatureClass 
    Fcls  = Workspace.OpenFeatureClass ("District")
     'IFeatureClass Fcls = Workspace.OpenFeatureClass ("District"); 
    dim Fly as new FeatureLayerClass
    ' IFeatureLayer Fly = new FeatureLayerClass(); 
     Fly.FeatureClass = Fcls  '; 
     MapCtr.Map.AddLayer (Fly)  '; 
     MapCtr.ActiveView.Refresh()  '; 
end sub
应该就是这样的,你用的类我没有用过,语法上就是这样的

上一个:VB如何将缩小的图片复制到剪贴板中去?
下一个:VB系统运行时提示“主程序不能是模块、类型、工程或窗体名”什么意思啊

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,