以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  ListView1中Checked=true的数量  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=132995)

--  作者:cd_tdh
--  发布时间:2019/4/3 16:39:00
--  ListView1中Checked=true的数量

老师,怎么统计ListView1中Checked=true的数量

我这样写逻辑有点问题,提示了两次,请老师看看怎么改。

If e.Form.Controls("DateTimePicker1").text <> "" Then
    Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
    Dim int As Integer = 0
    For Each r As WinForm.ListViewRow In lvw.Rows
        If r.Checked = True
            int = int+1
            Dim Result As DialogResult
            Result = MessageBox.Show("你本次考勤的人数为:" & int & "人,确定考勤吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If Result = DialogResult.Yes  Then
                Dim dr As Row= Tables("实名制考勤").AddNew()
                dr("姓名") = r.text
                dr("日期") = e.Form.Controls("DateTimePicker1").text
                dr.save
            Else
            End If
        Else
            MessageBox.show("你并没有选择任何人!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    Next
Else
    MessageBox.show("考勤日期不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If

 


--  作者:有点甜
--  发布时间:2019/4/3 17:47:00
--  
If e.Form.Controls("DateTimePicker1").text <> "" Then
    Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
    Dim int As Integer = 0
    For Each r As WinForm.ListViewRow In lvw.Rows
        If r.Checked = True
            int = int+1
        End If
    Next
    If Int = 0 Then
        MessageBox.show("你并没有选择任何人!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Dim Result As DialogResult
        Result = MessageBox.Show("你本次考勤的人数为:" & int & "人,确定考勤吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes  Then
            For Each r As WinForm.ListViewRow In lvw.Rows
                If r.Checked = True
                    Dim dr As Row= Tables("实名制考勤").AddNew()
                    dr("姓名") = r.text
                    dr("日期") = e.Form.Controls("DateTimePicker1").text
                    dr.save
                   
                End If
               
            Next
        End If
    End If
Else
    MessageBox.show("考勤日期不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If