Migrating VBA Function to vb.net

Discussion created by hamad2 on Nov 24, 2013
Latest reply on Dec 4, 2013 by hamad2
I am facing problem migrating this function from VBA  to vb.net.  I do appreciate  your help. I am using 10.1 and vs2010

Public Function GenerateClassBreaks(pFeatLayer As IFeatureLayer, sValFieldName As String, lNClass As Long, sClassification As String) As Variant

    ' classifies data using IClassify2 and Quantile classification,
    ' then creates ClassBreaksRenderer using these breaks,
    ' and assigns to first layer in the map
    On Error GoTo ErrorHandler
    Dim pFClass As IFeatureClass
    Dim pFeature As IFeature
    Dim pFCursor As IFeatureCursor
    Dim pTable As ITable
    Dim pClassifyGEN As IClassifyGEN
    Dim pTableHistogram As ITableHistogram
    Dim pHistogram As IHistogram
    Dim frqs As Variant, xVals As Variant
    Dim i As Integer
    Set pFClass = pFeatLayer.FeatureClass
    Set pFCursor = pFClass.Search(Nothing, False)
    Set pFeature = pFCursor.NextFeature
    Set pTable = pFClass
    'Set pClassifyGEN = New Quantile
    Select Case sClassification
        Case "Equal Interval"
            Set pClassifyGEN = New EqualInterval
        Case "Natual Breaks"
            Set pClassifyGEN = New NaturalBreaks
        Case "Quantile"
            Set pClassifyGEN = New Quantile
        Case "Standard Deviation"
            Set pClassifyGEN = New StandardDeviation
    End Select
    'Set pClassifyGEN = New EqualInterval
    Set pTableHistogram = New TableHistogram
    Set pHistogram = pTableHistogram
    pTableHistogram.Field = sValFieldName
    ' matches renderer field
    Set pTableHistogram.Table = pTable
    pHistogram.GetHistogram xVals, frqs
    pClassifyGEN.Classify xVals, frqs, lNClass
    ' use "iNClass" number of classes
    GenerateClassBreaks = pClassifyGEN.ClassBreaks
    GoTo Endproc
    MsgBox Err.Description, vbInformation, "GenerateClassBreaks"

    Set pFClass = Nothing
    Set pFeature = Nothing
    Set pFCursor = Nothing
    Set pTable = Nothing
    Set pClassifyGEN = Nothing
    Set pTableHistogram = Nothing
    Set pHistogram = Nothing
End Function