vba14-1.txt

来自「本书给出了AO的常用的VAB代码 可能是初学者很好的一本参考书」· 文本 代码 · 共 24 行

TXT
24
字号
Private Function FindLayer(strBrowseName As String) _
As ILayer
    ' Find the matching layer in the focus map.
    ' Return NOTHING if not found.
    Dim lngIndex As Long
    Dim pMxDocument As IMxDocument
    Dim pMap As IMap
    Dim pDataset As IDataset
    Set FindLayer = Nothing
    Set pMxDocument = Application.Document
    Set pMap = pMxDocument.FocusMap
    ' Loop through layers and search
    ' for the matching name.
    For lngIndex = 0 To (pMap.LayerCount - 1)
        If TypeOf pMap.Layer(lngIndex) Is FeatureLayer Then
            Set pDataset = pMap.Layer(lngIndex)
            If pDataset.BrowseName = strBrowseName Then
                Set FindLayer = pMap.Layer(lngIndex)
                Exit For
            End If
        End If
    Next lngIndex
End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?