YouTube | Facebook | Twitter  Feed

IDataStatics の利用

2016/9/1 (木)

Public Sub TheMacro()
 
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
     
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pMxDocument.FocusMap.Layer(0)
     
    Dim pDataset As IDataset
    Set pDataset = pFeatureLayer.FeatureClass
     
    Dim pFields As IFields
    Set pFields = ValidateFields(pDataset.Workspace, pFeatureLayer.FeatureClass.Fields)
 
End Sub
 
Public Function ValidateFields(pWorkspace As IWorkspace, pFields As IFields) As IFields
 
    'Create a new field checker and validate the fields.
    Dim pFieldChecker As IFieldChecker
    Set pFieldChecker = New FieldChecker
     
    Dim pValidatedFields As IFields
    Dim pEnumFieldError As IEnumFieldError
     
    Set pFieldChecker.ValidateWorkspace = pWorkspace
    pFieldChecker.Validate pFields, pEnumFieldError, pValidatedFields
     
    'pEnumFieldError.Reset
     
    Dim pFieldError As IFieldError
    Dim pField As IField
     
    'Display any errors that were found.
    If Not pEnumFieldError Is Nothing Then
     
        Set pFieldError = pEnumFieldError.Next
         
        Do Until pFieldError Is Nothing
         
         
            Set pField = pFields.Field(pFieldError.FieldIndex)
            Debug.Print pField.Name, pFieldError.FieldError
             
            Set pFieldError = pEnumFieldError.Next
        Loop
     
    End If
     
'    Dim pSqlKeywordDictionary As ISqlKeywordDictionary
'    Set pSqlKeywordDictionary = pFieldChecker.ValidateDictionary
'
'    Dim lngCount As Long
'    Dim blnResult As Boolean
'    blnResult = pSqlKeywordDictionary.Count(lngCount)
'
'
'
'    Debug.Print lngCount
'
'    Dim i As Long
'    For i = 0 To pSqlKeywordDictionary.Count(lngCount) - 1
'        Debug.Print pSqlKeywordDictionary.Name
'    Next i
     
    '
 
    Set ValidateFields = pValidatedFields
 
End Function

関連記事

  • この記事を書いた人

羽田 康祐

好きな地図投影法 はパース・クィンカンシャル図法とマクブライド・トーマス平極四次曲線図法。広島市出身。GIS上級技術者、Esri認定インストラクター、測量士補、潜水士、元PADIダイブマスター、四アマ。GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、発言は個人の見解です。

-プログラミング, ArcGIS
-,

© 2021 WINGFIELD since1981