'Codes are from Chapter 8 of Programming ArcObjects With 'VBA, by Kang-Tsung Chang. Private Sub UserForm_Initialize() cboMethod.AddItem "NaturalBreaks" cboMethod.AddItem "EqualInterval" cboMethod.AddItem "Quantile" End Sub Private Sub cmdRun_Click() ' Part 1: Define the feature layer and derive its histogram data. Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pLayer As IFeatureLayer Dim pTable As ITable Dim pTableHistogram As ITableHistogram Dim pHistogram As IHistogram Dim DataValues As Variant Dim DataFrequencies As Variant Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap Set pLayer = pMap.Layer(0) Set pTable = pLayer ' Define the table histogram. Set pTableHistogram = New TableHistogram pTableHistogram.Field = txtField.Value Set pTableHistogram.Table = pTable ' Derive the data values and frequencies from the histogram. Set pHistogram = pTableHistogram pHistogram.GetHistogram DataValues, DataFrequencies ' Part 2: Create a class breaks renderer. Dim pClassify As IClassify Dim Classes() As Double Dim pClassBreaksRenderer As IClassBreaksRenderer ' Set up the classification method. Select Case cboMethod.ListIndex Case 0 Set pClassify = New NaturalBreaks Case 1 Set pClassify = New EqualInterval Case 2 Set pClassify = New Quantile End Select ' Prepare a classify object. pClassify.SetHistogramData DataValues, DataFrequencies pClassify.Classify Val(txtNumber.Value) ' Create an array of class breaks. Classes = pClassify.ClassBreaks ' Prepare a class breaks renderer. Set pClassBreaksRenderer = New ClassBreaksRenderer With pClassBreaksRenderer .Field = txtField.Value .BreakCount = Val(txtNumber.Value) .MinimumBreak = Classes(0) End With ' Part 3: Create a color ramp. Dim pAlgoRamp As IAlgorithmicColorRamp Dim pColors As IEnumColors ' Prepare a color ramp. Set pAlgoRamp = New AlgorithmicColorRamp With pAlgoRamp .Algorithm = esriCIELabAlgorithm .ToColor = GetRGBColor(255, 0, 0) .FromColor = GetRGBColor(255, 255, 0) .Size = Val(txtNumber.Value) .CreateRamp (True) End With ' Store the colors. Set pColors = pAlgoRamp.Colors ' Part 4: Assign a color symbol, break, and label to each of the classes. Dim pFillSymbol As IFillSymbol Dim I As Integer For I = 0 To pClassBreaksRenderer.BreakCount - 1 Set pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = pColors.Next pClassBreaksRenderer.Symbol(I) = pFillSymbol pClassBreaksRenderer.Break(I) = Classes(I + 1) pClassBreaksRenderer.Label(I) = CSng(Classes(I)) & " - " & CSng(Classes(I + 1)) Next I ' Part 5: Draw the graduated color map. Dim pGeoFeatureLayer As IGeoFeatureLayer ' Assign the renderer to the feature layer. Set pGeoFeatureLayer = pLayer Set pGeoFeatureLayer.Renderer = pClassBreaksRenderer ' Refresh the map and its table of contents. pMxDoc.ActiveView.PartialRefresh esriViewGeography, pLayer, Nothing pMxDoc.UpdateContents End Sub Private Function GetRGBColor(R As Long, G As Long, B As Long) Dim pColor As IRgbColor Set pColor = New RgbColor pColor.Red = R pColor.Green = G pColor.Blue = B GetRGBColor = pColor End Function Private Sub cmdCancel_Click() End End Sub