Using pCalculator with fields and variables

Discussion created by Nelsonucv on Jun 16, 2010
Latest reply on Jun 16, 2010 by jamesfreddyc
Guys, i'ven experiencing many troubles using the pCalculator with variables, values from a form and fields.  I need that some values from a form, a variable that i previosly have declared and a field perform an aritmethical operation.

Can anyone help me with the sintax in .expression? the code is below

Thanks in advance

Public Sub Cal_perd_hum()
Dim pMxDoc As IMxDocument
    Dim pFeatureLayer As IFeatureLayer
    Dim pFeatureClass As IFeatureClass
    Set pMxDoc = ThisDocument
    Set pFeatureLayer = pMxDoc.FocusMap.Layer(1)
    Set pFeatureClass = pFeatureLayer.FeatureClass
    Dim pFields As IFields
    Dim ii As Integer
    Dim pQueryFilter As IQueryFilter
    Dim pCursor As ICursor
    Dim pCalc As ICalculator
    Set pFeatureLayer = pFeatureLayer
    Set pFeatureClass = pFeatureLayer.FeatureClass
    Set pFields = pFeatureClass.Fields
    Dim HL1, HL2, HL3, HL4, HL5 As Double
    Dim HG1, HG2, HG3, HG4, HG5 As Double
    Dim FM1, FM2, FM3, FM4, FM5 As Double
    'Valores del formulario de heridos leves
    HL1 = Val(FrmPerdida.txt_HL1.Text)
    HL2 = Val(FrmPerdida.txt_HL2.Text)
    HL3 = Val(FrmPerdida.txt_HL3.Text)
    HL4 = Val(FrmPerdida.txt_HL4.Text)
    HL5 = Val(FrmPerdida.txt_HL5.Text)
    'Valores del formulario de heridos graves
    HG1 = Val(FrmPerdida.txt_HG1.Text)
    HG2 = Val(FrmPerdida.txt_HG2.Text)
    HG3 = Val(FrmPerdida.txt_HG3.Text)
    HG4 = Val(FrmPerdida.txt_HG4.Text)
    HG5 = Val(FrmPerdida.txt_HG5.Text)
    'Valores del formulario de fallecidos o muertos
    FM1 = Val(FrmPerdida.txt_FM1.Text)
    FM2 = Val(FrmPerdida.txt_FM2.Text)
    FM3 = Val(FrmPerdida.txt_FM3.Text)
    FM4 = Val(FrmPerdida.txt_FM4.Text)
    FM5 = Val(FrmPerdida.txt_FM5.Text)
    '++++++++++++++++++++++++++++++Calculo del valor a tomar dependiendo del DM para las perdidas+++++++++++++++++++++++++
     ii = pFields.FindField("Dm")
    'Preparacion del cursor para encontrar el criterio seleccionado.
    Set pQueryFilter = New QueryFilter
    pQueryFilter.WhereClause = "Dm >= DC1 AND Dm <= DC2"
    Set pCursor = pFeatureClass.Update(pQueryFilter, True)
    ' Uso del cursor para calcular el valor.
    Set pCalc = New Calculator
    With pCalc
        Set .Cursor = pCursor
           'here is when the code crash
            '.Expression = " FM5 * [POBLACION] / FrmPerdida.txt_FM4.Text"
            .Field = "Pfm"
        End With
       End Sub