Split mathematical formula RRS feed

  • Question

  • Hi,
    I need to be able to split a math formula into its parts...

    eg, A + B / C - D

    I want to be able to get the A B C and D parts out as seperate objects (array etc).

    Anyone got any helpfull hints or ideas?

    Thanks heaps for any help!


    Wednesday, January 9, 2008 10:10 AM


  • I must not be understanding what you're trying to do because this seems like it would be pretty straight forward.  You should be able to obtain values from various objects and then do a calculation.  It would be something like this . . .


    Code Block

    Dim A As Double = CType(?????, Double) 'Replace ????? with the first object property

    Dim B As Double = CType(?????, Double) 'Replace ????? with the second object property

    Dim C As Double = CType(?????, Double) 'Replace ????? with the third object property

    Dim D As Double = CType(?????, Double) 'Replace ????? with the last object property

    Dim Answer As Double = A + B / C - D


    Now, let's assume:

    A = 8

    B = 4

    C = 2

    D = 1


    Will your formula calculate 12, 5 or 9?

    Wednesday, January 9, 2008 1:43 PM