' Returns TRUE if the Table can be edited outside of an edit session Function CanEditWOEditSession(pTable As ITable) As Boolean Dim pVersionedObject As IVersionedObject Dim pObjClassInfo2 As IObjectClassInfo2 Dim bolVersioned As Boolean Dim bolEditable As Boolean ' See if the data is versioned If Not TypeOf pTable Is IVersionedObject Then bolVersioned = False Else Set pVersionedObject = pTable bolVersioned = pVersionedObject.IsRegisteredAsVersioned End If ' Check the CanBypassEditSession property Set pObjClassInfo2 = pTable bolEditable = pObjClassInfo2.CanBypassEditSession If bolEditable And Not bolVersioned Then CanEditWOEditSession = True Else CanEditWOEditSession = False End If End Function Public Sub Neighborinfo() 'Initialization variable-------------------------------------------- Dim pMxDoc As IMxDocument Dim pMap As IMap 'Variables for feature selection------------------------------------ Dim pEnumFeature As IEnumFeature Dim pFeature As IFeature Dim newPFeature As IFeature Dim pFeatureLayer As IFeatureLayer Dim pFeatCursor As IFeatureCursor Dim pSelFeatCursor As IFeatureCursor Dim pFcls As IFeatureClass 'Variables for spatial relation operation--------------------------- Dim i As Long Dim pArea As IArea Dim pSelArea As IArea Dim pRelOp As IRelationalOperator 'Initialization----------------------------------------------------- Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap 'Make certain that layer with farm boundaries is the first layer in the map (or change index on pMap.Layer(0)) Set pFeatureLayer = pMap.Layer(0) 'Get the field name and total number of features--------------------- Dim pFlds As IFields Dim totalFCount As Long Set pFcls = pFeatureLayer.FeatureClass Set pFlds = pFcls.Fields totalFCount = pFcls.FeatureCount(Nothing) If (totalFCount < 1) Then MsgBox ("Error in getting the number of features in the layer!") Exit Sub End If 'Get the field name and total number of features---------------------- ' Table editing preparations-------------------------------------------------------------- 'This calculation is to be done outside of an edit session. Dim pEditor As IEditor Dim pID As New UID pID = "esriGeoDatabase.Editor" Set pEditor = ThisDocument.Parent.FindExtensionByCLSID(pID) If pEditor.EditState = esriStateEditing Then MsgBox "This tool requires that ArcMap is not in edit mode" Exit Sub End If ' Also, check to see if the selected layer supports editing without an edit session------- If Not CanEditWOEditSession(pFeatureLayer.FeatureClass) Then MsgBox "This layer cannot be edited outside of an edit session" Exit Sub End If ' Get an exclusive schema lock on the dataset--------------------------------------------- ' If they are not already there, make the new field and add it to the feature class------- Dim pFieldEdit As IFieldEdit If pFeatureLayer.FeatureClass.FindField("mean_edu") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_edu" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_edu") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_edu" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("neighbors") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "neighbors" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("edu_count") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "edu_count" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_age") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_age" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("age_count") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "age_count" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("medu_age") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "medu_age" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_earn") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_earn" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_earn") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_earn" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("earn_cnt") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "earn_cnt" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_gr") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_gr" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_gr") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_gr" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_hscol") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_hscol" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_hscol") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_hscol" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_val") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_val" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_val") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_val" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_vac") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_vac" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_vac") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_vac" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_eac") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_eac" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_eac") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_eac" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("val_cnt") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "val_cnt" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_com") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_com" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_com") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_com" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_gram") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_gram" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_gram") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_gram" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_high") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_high" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_high") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_high" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("mean_coll") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "mean_coll" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If If pFeatureLayer.FeatureClass.FindField("max_coll") = -1 Then Set pFieldEdit = New esriGeoDatabase.Field pFieldEdit.Name = "max_coll" pFieldEdit.Type = esriFieldTypeString pFeatureLayer.FeatureClass.AddField pFieldEdit End If ' Table editing preparations--------------------------------------------------------------- '******* IMPORTANT Note: MUST use FeatureClass.Update to update later****** IMPORTANT Set pSelFeatCursor = pFeatureLayer.FeatureClass.Update(Nothing, False) Set pFeature = pSelFeatCursor.NextFeature If pFeature.Shape.GeometryType <> esriGeometryPolygon Then MsgBox ("This script only works for polygon feature layers!") Exit Sub End If ' Find the field in which value will be assigned to------------------------------------ ' Declaring existing fields Dim srcidFldInd As Double ' FID field of each feature (polygon) Dim edFldInd As Long Dim exbFldInd As Double Dim exeFldInd As Double Dim exfFldInd As Double Dim exgFldInd As Double Dim exhFldInd As Double Dim exiFldInd As Long Dim exjFldInd As Long Dim exkFldInd As Double Dim exlFldInd As Long Dim exmFldInd As Long Dim exnFldInd As Long Dim exoFldInd As Double Dim expFldInd As Double Dim exqFldInd As Double Dim exrFldInd As Double Dim exsFldInd As Double ' Declaring constructed fields Dim idFldInd As Double ' Newly created id field (mean_edu) Dim cnteduFldInd As Long ' Field to store count of neighbors with edu Dim cntFldInd As Long ' Field to store count of total number of neighbors Dim edmaxFldInd As Long ' Field to store max edu Dim coeFldInd As Double Dim cofFldInd As Long Dim cogFldInd As Double Dim cohFldInd As Double Dim coiFldInd As Double Dim cojFldInd As Long Dim cokFldInd As Double Dim colFldInd As Double Dim comFldInd As Double Dim conFldInd As Double Dim cooFldInd As Double Dim copFldInd As Double Dim coqFldInd As Double Dim corFldInd As Double Dim cosFldInd As Double Dim cotFldInd As Double Dim covFldInd As Long Dim coxFldInd As Double Dim coyFldInd As Double Dim cozFldInd As Double Dim coaaFldInd As Double Dim cobbFldInd As Double Dim coccFldInd As Double Dim coddFldInd As Double Dim coeeFldInd As Double srcidFldInd = pSelFeatCursor.FindField("total_sch") idFldInd = pSelFeatCursor.FindField("mean_edu") edFldInd = pSelFeatCursor.FindField("edu_repo") cnteduFldInd = pSelFeatCursor.FindField("edu_count") edmaxFldInd = pSelFeatCursor.FindField("max_edu") cntFldInd = pSelFeatCursor.FindField("neighbors") exbFldInd = pSelFeatCursor.FindField("acreage") exeFldInd = pSelFeatCursor.FindField("graded_sch") exfFldInd = pSelFeatCursor.FindField("high_sch") exgFldInd = pSelFeatCursor.FindField("incumb") exhFldInd = pSelFeatCursor.FindField("farm_value") exiFldInd = pSelFeatCursor.FindField("byear") exjFldInd = pSelFeatCursor.FindField("multipart") exkFldInd = pSelFeatCursor.FindField("earnings") exlFldInd = pSelFeatCursor.FindField("earn_repo") exmFldInd = pSelFeatCursor.FindField("value_repo") exnFldInd = pSelFeatCursor.FindField("inc_repo") exoFldInd = pSelFeatCursor.FindField("i_to_v") expFldInd = pSelFeatCursor.FindField("e_to_v") exqFldInd = pSelFeatCursor.FindField("college") exrFldInd = pSelFeatCursor.FindField("common") exsFldInd = pSelFeatCursor.FindField("grammar") coeFldInd = pSelFeatCursor.FindField("mean_age") cofFldInd = pSelFeatCursor.FindField("age_count") cogFldInd = pSelFeatCursor.FindField("medu_age") cohFldInd = pSelFeatCursor.FindField("mean_earn") coiFldInd = pSelFeatCursor.FindField("max_earn") cojFldInd = pSelFeatCursor.FindField("earn_cnt") cokFldInd = pSelFeatCursor.FindField("mean_gr") colFldInd = pSelFeatCursor.FindField("max_gr") comFldInd = pSelFeatCursor.FindField("mean_hscol") conFldInd = pSelFeatCursor.FindField("max_hscol") cooFldInd = pSelFeatCursor.FindField("mean_val") copFldInd = pSelFeatCursor.FindField("max_val") coqFldInd = pSelFeatCursor.FindField("mean_vac") corFldInd = pSelFeatCursor.FindField("max_vac") cosFldInd = pSelFeatCursor.FindField("mean_eac") cotFldInd = pSelFeatCursor.FindField("max_eac") covFldInd = pSelFeatCursor.FindField("val_cnt") coxFldInd = pSelFeatCursor.FindField("mean_com") coyFldInd = pSelFeatCursor.FindField("max_com") cozFldInd = pSelFeatCursor.FindField("mean_gram") coaaFldInd = pSelFeatCursor.FindField("max_gram") cobbFldInd = pSelFeatCursor.FindField("mean_high") coccFldInd = pSelFeatCursor.FindField("max_high") coddFldInd = pSelFeatCursor.FindField("mean_coll") coeeFldInd = pSelFeatCursor.FindField("max_coll") ' Find the field in which value will be assigned to------------------------------------ ' Status bar preparations--------------------------------------------------------------- Dim pStatusBar As IStatusBar Dim pProgbar As IStepProgressor Set pStatusBar = ThisDocument.Parent.StatusBar Set pProgbar = pStatusBar.ProgressBar pProgbar.Position = 0 pStatusBar.ShowProgressBar "Working...", 0, totalFCount, 1, True ' Status bar preparations--------------------------------------------------------------- ' Loop for ALL the features (polygons) in the layer------------------------------- Do While (Not pFeature Is Nothing) Set pSelArea = pFeature.Shape 'Get the shape geometry of the selected feature--- Set pRelOp = pSelArea i = 0 j = 0 k = 0 l = 0 m = 0 Dim meanedu As Double Dim maxedu As Double Dim nedu As Double Dim educheck As Long Dim earncheck As Long Dim inccheck As Long Dim valcheck As Long Dim nearn As Long Dim nval As Long Dim nage As Long Dim meduage As Double Dim meanhscol As Double Dim hscol As Double Dim maxhscol As Double Dim meangraded As Double Dim maxgraded As Double Dim meanage As Double Dim agecheck As Long Dim acreage As Double Dim meanearn As Double Dim maxearn As Double Dim earnac As Double Dim maxearnac As Double Dim meanval As Double Dim maxval As Double Dim valac As Double Dim mvalac As Double Dim maxvalac As Double Dim meancom As Double Dim maxcom As Double Dim meangram As Double Dim maxgram As Double Dim meanhigh As Double Dim maxhigh As Double Dim meancoll As Double Dim maxcoll As Double Dim comm As Double Dim gram As Double Dim high As Double Dim coll As Double nedu = 0 meanedu = 0 maxedu = 0 educheck = 0 earncheck = 0 inccheck = 0 valcheck = 0 nearn = 0 nval = 0 nage = 0 meduage = 0 meanhscol = 0 hscol = 0 maxhscol = 0 meangraded = 0 maxgraded = 0 meanage = 0 agecheck = 0 earncheck = 0 valcheck = 0 inccheck = 0 acreage = 0 meanearn = 0 maxearn = 0 earnac = 0 mearnac = 0 maxearnac = 0 meanval = 0 maxval = 0 valac = 0 mvalac = 0 maxvalac = 0 meancom = 0 maxcom = 0 meangram = 0 maxgram = 0 meanhigh = 0 maxhigh = 0 meancoll = 0 maxcoll = 0 comm = 0 gram = 0 high = 0 coll = 0 ' STOPPED EDITING CODE HERE, NEED TO ADD CALCULATIONS FOR MEAN/MAX COM,GRAM,HIGH,COLL ' Loop for ALL the features (polygons) in the layer-------------------------------------- Set pFeatCursor = pFeatureLayer.Search(Nothing, False) 'Get all the features in the layer Set newPFeature = pFeatCursor.NextFeature Do While (Not newPFeature Is Nothing) Set pArea = newPFeature.Shape If pRelOp.Touches(pArea) Then j = j + 1 'j indexes all neighbors agecheck = newPFeature.Value(exiFldInd) If (agecheck > 0 And agecheck < 2000) Then k = k + 1 meanage = meanage + newPFeature.Value(exiFldInd) End If educheck = newPFeature.Value(edFldInd) If educheck = 1 Then i = i + 1 'i indexes neighbors with education reported meanedu = meanedu + newPFeature.Value(srcidFldInd) If newPFeature.Value(srcidFldInd) > maxedu Then maxedu = newPFeature.Value(srcidFldInd) meduage = newPFeature.Value(exiFldInd) End If meanhscol = meanhscol + newPFeature.Value(exfFldInd) + newPFeature.Value(exqFldInd) hscol = newPFeature.Value(exfFldInd) + newPFeature.Value(exqFldInd) If i = 1 Then maxhscol = newPFeature.Value(exfFldInd) + newPFeature.Value(exqFldInd) End If If hscol > maxhscol Then 'maxhscol = newPFeature.Value(exfFldInd) + newPFeature.Value(exqFldInd) maxhscol = hscol End If meangraded = meangraded + newPFeature.Value(exeFldInd) If newPFeature.Value(exeFldInd) > maxgraded Then maxgraded = newPFeature.Value(exeFldInd) End If meancom = meancom + newPFeature.Value(exrFldInd) comm = newPFeature.Value(exrFldInd) If i = 1 Then maxcom = newPFeature.Value(exrFldInd) End If If comm > maxcom Then maxcom = comm End If meangram = meangram + newPFeature.Value(exsFldInd) gram = newPFeature.Value(exsFldInd) If i = 1 Then maxgram = newPFeature.Value(exsFldInd) End If If gram > maxgram Then maxgram = gram End If meanhigh = meanhigh + newPFeature.Value(exfFldInd) high = newPFeature.Value(exfFldInd) If i = 1 Then maxcom = newPFeature.Value(exfFldInd) End If If high > maxhigh Then maxhigh = high End If meancoll = meancoll + newPFeature.Value(exqFldInd) coll = newPFeature.Value(exqFldInd) If i = 1 Then maxcoll = newPFeature.Value(exqFldInd) End If If coll > maxcoll Then maxcoll = coll End If End If ' Go back to define variables beginning at this point earncheck = newPFeature.Value(exlFldInd) valcheck = newPFeature.Value(exmFldInd) inccheck = newPFeature.Value(exnFldInd) acreage = newPFeature.Value(exbFldInd) If earncheck = 1 Then l = l + 1 meanearn = meanearn + newPFeature.Value(exkFldInd) If newPFeature.Value(exkFldInd) > maxearn Then maxearn = newPFeature.Value(exkFldInd) End If earnac = newPFeature.Value(exkFldInd) / acreage mearnac = mearnac + earnac If earnac > maxearnac Then maxearnac = earnac End If End If If valcheck = 1 Then m = m + 1 meanval = meanval + newPFeature.Value(exhFldInd) If newPFeature.Value(exhFldInd) > maxval Then maxval = newPFeature.Value(exhFldInd) End If valac = newPFeature.Value(exhFldInd) / acreage mvalac = mvalac + valac If valac > maxvalac Then maxvalac = valac End If End If End If Set newPFeature = pFeatCursor.NextFeature Loop ' Loop for ALL the features (polygons) in the layer-------------------------------------- If i > 0 Then meanedu = meanedu / i meangraded = meangraded / i meanhscol = meanhscol / i meancom = meancom / i meangram = meangram / i meanhigh = meanhigh / i meancoll = meancoll / i End If If k > 0 Then meanage = meanage / k End If If l > 0 Then meanearn = meanearn / l mearnac = mearnac / l End If If m > 0 Then meanval = meanval / m mvalac = mvalac / m End If pFeature.Value(idFldInd) = meanedu pFeature.Value(cnteduFldInd) = i pFeature.Value(cntFldInd) = j pFeature.Value(edmaxFldInd) = maxedu pFeature.Value(coeFldInd) = meanage pFeature.Value(cofFldInd) = k pFeature.Value(cogFldInd) = meduage pFeature.Value(cokFldInd) = meangraded pFeature.Value(colFldInd) = maxgraded pFeature.Value(comFldInd) = meanhscol pFeature.Value(conFldInd) = maxhscol pFeature.Value(cohFldInd) = meanearn pFeature.Value(coiFldInd) = maxearn pFeature.Value(cojFldInd) = l pFeature.Value(cosFldInd) = mearnac pFeature.Value(cotFldInd) = maxearnac pFeature.Value(cooFldInd) = meanval pFeature.Value(copFldInd) = maxval pFeature.Value(coqFldInd) = mvalac pFeature.Value(corFldInd) = maxvalac pFeature.Value(covFldInd) = m pFeature.Value(coxFldInd) = meancom pFeature.Value(coyFldInd) = maxcom pFeature.Value(cozFldInd) = meangram pFeature.Value(coaaFldInd) = maxgram pFeature.Value(cobbFldInd) = meanhigh pFeature.Value(coccFldInd) = maxhigh pFeature.Value(coddFldInd) = meancoll pFeature.Value(coeeFldInd) = maxcoll pSelFeatCursor.UpdateFeature pFeature ' Write the field meanedu = 0 i = 0 j = 0 k = 0 l = 0 m = 0 nedu = 0 meanedu = 0 maxedu = 0 educheck = 0 earncheck = 0 inccheck = 0 valcheck = 0 nearn = 0 nval = 0 nage = 0 meduage = 0 meanhscol = 0 hscol = 0 maxhscol = 0 meangraded = 0 maxgraded = 0 meanage = 0 agecheck = 0 earncheck = 0 valcheck = 0 inccheck = 0 acreage = 0 meanearn = 0 maxearn = 0 earnac = 0 mearnac = 0 maxearnac = 0 meanval = 0 maxval = 0 valac = 0 mvalac = 0 maxvalac = 0 meancom = 0 maxcom = 0 meangram = 0 maxgram = 0 meanhigh = 0 maxhigh = 0 meancoll = 0 maxcoll = 0 comm = 0 gram = 0 high = 0 coll = 0 hscol = 0 Set pFeature = pSelFeatCursor.NextFeature pStatusBar.StepProgressBar Loop ' Loop for ALL the SELECTED features (polygons) in the layer------------------------------- pStatusBar.HideProgressBar ' House keeping stuff ---------------------------------------------------------------------- Set pEnumFeature = Nothing Set pFeature = Nothing Set newPFeature = Nothing Set pFeatureLayer = Nothing Set pFeatCursor = Nothing Set pSelFeatCursor = Nothing Set pFcls = Nothing Set pStatusBar = Nothing Set pProgbar = Nothing Set pArea = Nothing Set pSelArea = Nothing Set pRelOp = Nothing End Sub