【问题标题】:How to sum field in lightswitch app如何在灯开关应用程序中对字段求和
【发布时间】:2015-02-16 21:44:33
【问题描述】:

您好,我正在尝试创建一个用于记录替代时间的小应用程序。

下面的代码不会返回用户停留时间的总值。

2 表 刘 上尉日期。 lieuAdd 布尔选择列表 True, False。 LieuHours 十进制。 lieuTotal 十进制计算域。

用户 用户名字符串。 姓氏字符串。 名字字符串。 电话 电话。 电子邮件电子邮件地址。

一个(用户)到多个(代替)

我想显示一个人在 lieutotal 字段中的总时间 运行总计,因此当用户查看他们的最后一条记录时,它会显示最后一笔交易以及他们有多少空闲时间。

计算域代码

命名空间 LightSwitchApplication

Public Class Lieu

    Private Sub LieuTotal_Compute(ByRef result As Decimal)
        ' Set result to the desired field value
        Dim Total As Decimal

        If LieuAdd = True Then
            If LieuTotal = 0 Then
                Total = LieuHours
            Else
                Total = LieuTotal + LieuHours
                result = total
            End If
        Else


            Total = LieuTotal - LieuHours

        End If
    End Sub
End Class

结束命名空间

【问题讨论】:

    标签: vb.net-2010 visual-studio-lightswitch


    【解决方案1】:

    由于您要计算总数,因此需要使用 For Each 循环。假设表的名称是 Lieus,您的代码应该是这样的:

        Private Sub LieuTotal_Compute(ByRef result As Decimal) 
        ' Set result to the desired field value 
        ' 
        For Each Lieu In Lieus
            If Lieu.LieuAdd = True Then 
              result = result + Lieu.LieuHours
            Else
              result = result - Lieu.LieuHours
            End If
         Next          
        End Sub
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多