Skip to Content
avatar image
Former Member

How to do addition of two columns cells in Matrix.

Hi All,

I tried following code on LostFocus event of Mtrix. I want to do addition of two columns cells of matrix and addtion display in third column. I tried the following code but in this I am getting the column value and when i enterd any value in columns cells it disappear when i move to next column cells.

Can anybody suggest me how to do it ?

Dim i As Integer

Dim v1, v2 As String

matrix.Columns.Item("V_4").DataBind.SetBound(True, "", "matrixds")

If pVal.ColUID = "V_4" Then

For i = 0 To matrix.RowCount - 1

v1 = matrix.Columns.Item("V_5").Cells.Item(i + 1).Specific.Value

v2 = matrix.Columns.Item("V_4").Cells.Item(i + 1).Specific.Value

Dim v3 As Integer = CInt(v1) + CInt(v2)

matrix.Columns.Item("V_3").Cells.Item(i + 1).Specific.Value = v3.ToString()

Next

End If

Thanks and Regards,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 05, 2008 at 10:34 AM

    Harish,

    Try this, in the below code i'm doing a similar operation, just change the operation...

    Dim objEdit, objEdit2 As SAPbouiCOM.EditText
    objEdit = objMatrix.Columns.Item("V_14").Cells.Item(pVal.Row).Specific
    dblQty = objEdit.String
    objEdit = objMatrix.Columns.Item("V_13").Cells.Item(pVal.Row).Specific
    dblUnitPrice = objEdit.String
    objEdit = objMatrix.Columns.Item("V_10").Cells.Item(pVal.Row).Specific
    dblRowTot = dblQty * dblUnitPrice
    objEdit.String = dblRowTot

    the above code is executed in LOST FOCUS in the BeforeAction = False condition.

    Hope it helps,

    Vasu Natari.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 05, 2008 at 10:36 AM

    Hi,

    u bind all the columns to the datasource in the matrix.then the value does not disappear.

    Change ur code as follows:

    Use the databind in formload

    matrix.Columns.Item("V_4").DataBind.SetBound(True, "", "matrixds1")

    matrix.Columns.Item("V_5").DataBind.SetBound(True, "", "matrixds2")

    matrix.Columns.Item("V_3").DataBind.SetBound(True, "", "matrixds3")

    -


    Dim v1, v2 As sapbouicom.edittext

    If pVal.ColUID = "V_4" Then

    v1 = matrix.Columns.Item("V_5").Cells.Item(pVal.row).Specific

    v2 = matrix.Columns.Item("V_4").Cells.Item(pVal.row).Specific

    v3= matrix.Columns.Item("V_3").Cells.Item(pVal.row).Specific

    v3.Value = v1 .Value + v2.Value

    End If

    Kind Regards

    Mohana

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 05, 2008 at 11:36 AM

    Hi..

    ur using userdefined form and ur total column is non-editable

    use this code..

    Dim i As Integer

    Dim v1, v2 As String

    matrix.Columns.Item("V_4").DataBind.SetBound(True, "", "matrixds")

    If pVal.ColUID = "V_4" Then

    For i = 0 To matrix.RowCount - 1

    v1 = matrix.Columns.Item("V_5").Cells.Item(i + 1).Specific.Value

    v2 = matrix.Columns.Item("V_4").Cells.Item(i + 1).Specific.Value

    Dim v3 As Integer = CInt(v1) + CInt(v2)

    matrix.Columns.Item("V_3").Cells.Item(i + 1).Specific.Value = v3.ToString()

    Next

    End If

    oForm.Update()

    Regards...

    Billa 2007

    Add comment
    10|10000 characters needed characters exceeded