none
sum columns in lightswitch chart in series gantt chart RRS feed

  • Question

  • In lightswitch I have a single table(entity) with 3 columns value1, value2 and sumOf. Excluding RIA services which is beyond my ablilities(for now LOL). I would like to add value1 to value2 and the result is calculated in sumOf column. I tried making sumOf a calculated property with the code. result = value1 + value2, this appears to concantenate the two values?? However value1 * value2 yeilds the correct result.  My learning project is to create a simple gantt chart. Yikes! Where is the sum function VBA? Thanks for your time and patience with such a simple query!

    Friday, March 8, 2013 1:27 AM

Answers

  • Sounds like either value1 or value2 is a string. You may need to convert value1 and value2 to numeric data types first. Depending on what type of numeric type you want, you can use parsing methods such as (in the case of integers): CInt(), Convert.ToInt32(), Int32.Parse(), or Int32.TryParse().

    Justin Anderson, LightSwitch Development Team

    Friday, March 8, 2013 4:25 AM
    Moderator

All replies

  • I just went through a test application, Created an entity called Table1 :)

    Added Fields, id, Field1_1 and Field_2.

    Added another Field called SumOf, then in the properties on the right converted the Entiry to IsComputed, then edited the Method by clicking the Edit Method link ad added the following code.

            Private Sub SumOf_Compute(ByRef result As String)
                ' Set result to the desired field value
                result = Field1_1 + Field_2
            End Sub
    

    Then added an editable grid screen and run the application, After entering 2 and 6 for the fields the sum of worked by adding them together...
    Friday, March 8, 2013 2:48 AM
  • Sounds like either value1 or value2 is a string. You may need to convert value1 and value2 to numeric data types first. Depending on what type of numeric type you want, you can use parsing methods such as (in the case of integers): CInt(), Convert.ToInt32(), Int32.Parse(), or Int32.TryParse().

    Justin Anderson, LightSwitch Development Team

    Friday, March 8, 2013 4:25 AM
    Moderator
  • Thanks for the support!

    Friday, March 8, 2013 1:11 PM