Passing Variables

2060
0
05-19-2010 12:37 PM
TysonHart
New Contributor
I'm new to learning scripting and I am having trouble passing the variables in the code below.  I have practiced simple passing of variables, but I have been stuck on this for a few days now.

My question is, what should my variables be set to and/or what is the process to make this code run?

I'm pretty green at this, so it may have to be step-by-step.

Thanks in advance,

[HTML]Public Sub GetLayerZonalMinMax(pRasLayer As IRasterLayer, ByRef myMin As Double, ByRef myMax As Double)
    If pRasLayer.Raster Is Nothing Then Exit Sub
   
    Dim pMxDoc As IMxDocument
    Dim pMap As IMap
    Dim pCompositeLayer As ICompositeLayer
    Dim pLayer As ILayer
    Set pMxDoc = ThisDocument
    Set pMap = pMxDoc.FocusMap
    Set pCompositeLayer = pMap.Layer(0)
    Set pLayer = pCompositeLayer.Layer(0)
    Dim pFeaturelayer As IFeatureLayer
    Set pFeaturelayer = pLayer
    Dim pDataset As IDataset
    Set pDataset = pFeaturelayer.FeatureClass
    Dim sPath As String
    sPath = pDataset.Workspace.PathName & "\" & pDataset.Name & ".shp"
   
    Dim outputTable As String
    Dim tablePath As String
    tablePath = "C:\temp"
    Dim tableName As String
    tableName = "output2.dbf"
    'tableName = pRasLayer.Name + ".dbf"
    outputTable = tablePath + "\" + tableName
    Dim rasPath As String
    rasPath = pRasLayer.FilePath
   
    Dim gp As Object
    Set gp = CreateObject("esriGeoprocessing.GPDispatch.1")
    gp.CheckOutExtension "spatial"
   
    ' Load required toolboxes...
    gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx"
    gp.ZonalStatisticsAsTable_sa sPath, "POLYTYPE", rasPath, outputTable, "DATA"
   
    Dim pWSF As IWorkspaceFactory
    Dim pFeatureWS As IFeatureWorkspace
    Dim pTable As ITable
   
    Set pWSF = New ShapefileWorkspaceFactory
    Set pFeatureWS = pWSF.OpenFromFile(tablePath, 0)
    Set pTable = pFeatureWS.OpenTable(tableName)
    Dim myMin As Double
    Dim myMax As Double
    myMin = pTable.GetRow(0).value(4)
    myMax = pTable.GetRow(0).value(5)
    Set pDataset = pTable
    pDataset.Delete
   
End Sub[/HTML]
0 Kudos
0 Replies