YouTube | Facebook | X(Twitter) | RSS

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エンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

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