Vb6 如何在带有数据库的listview中使用dtpicker筛选日期

Vb6 如何在带有数据库的listview中使用dtpicker筛选日期,vb6,Vb6,我正在创建一个工资单系统,我想使用dtpicker在listview中搜索日期,并计算每日工资的数量,请帮助我 以下是您如何仅使用ListView中的数据汇总每日费率列的方法: Private Sub Command1_Click() Dim objItem As ListItem Dim iCounter As Integer Dim lngDailyRate As Long Dim iDateSubitemIndex As Integer Dim

我正在创建一个工资单系统,我想使用dtpicker在listview中搜索日期,并计算每日工资的数量,请帮助我


以下是您如何仅使用ListView中的数据汇总每日费率列的方法:

Private Sub Command1_Click()
    Dim objItem As ListItem
    Dim iCounter As Integer
    Dim lngDailyRate As Long

    Dim iDateSubitemIndex As Integer
    Dim iDailyRateSubitemIndex As Integer

    ' Update these to reflect your ListView
    iDateSubitemIndex = 1
    iDailyRateSubitemIndex = 2

    For iCounter = 1 To ListView1.ListItems.Count

        ' Get List Item
        Set objItem = ListView1.ListItems.item(iCounter)

        ' Check Date
        If CDate(objItem.SubItems(iDateSubitemIndex)) = DTPicker1 Then
            lngDailyRate = lngDailyRate + CLng(objItem.SubItems(iDailyRateSubitemIndex))
        End If

    Next

    MsgBox "Daily Rate for " & DTPicker1 & " is " & lngDailyRate

End Sub

请更新两个子项索引变量以匹配ListView中的列。这些用于从正确的列中检索数据。

您能给我们一个listview包含哪些内容的示例吗?什么是“每日费率的数量”?您好,先生,谢谢您的回复,我最近编辑了我的帖子我附上的图片您希望您的listview仅显示在DTR区域中定义的时间段内工作的员工吗?是的,先生,并获取每日费率的总和列是否可能?listview中的数据来自数据库?如果是这样,您可以在SELECT语句中添加WHERE子句来指定日期范围,还可以创建一个SUM列来汇总每日费率列。非常感谢您,先生。上帝保佑,如何标记此问题已解决?它可以工作,先生,但它只在dtpicker中计算两个日期,如果我选择09-12-19到09-12-15,它只添加两个日期,我希望将输出添加到12,13,14,15 dates=1680
如果CDate(objItem.SubItems(iDateSubitemIndex))>=DTPickerStart和CDate(objItem.SubItems(iDateSubitemIndex))
MsgBox“每日费率为”&DTPickerStart&“至”&dtpickernd&“为”&lngDailyRate
。将
DTPickerStart
DTPickerEnd
替换为您的DTPicker控件的名称。这两种比较都具有
=
。其中一种需要不同。
Private Sub Command1_Click()
    Dim objItem As ListItem
    Dim iCounter As Integer
    Dim lngDailyRate As Long

    Dim iDateSubitemIndex As Integer
    Dim iDailyRateSubitemIndex As Integer

    ' Update these to reflect your ListView
    iDateSubitemIndex = 1
    iDailyRateSubitemIndex = 2

    For iCounter = 1 To ListView1.ListItems.Count

        ' Get List Item
        Set objItem = ListView1.ListItems.item(iCounter)

        ' Check Date
        If CDate(objItem.SubItems(iDateSubitemIndex)) = DTPicker1 Then
            lngDailyRate = lngDailyRate + CLng(objItem.SubItems(iDailyRateSubitemIndex))
        End If

    Next

    MsgBox "Daily Rate for " & DTPicker1 & " is " & lngDailyRate

End Sub