3 Replies - 1812 Views - Last Post: 26 March 2014 - 05:24 AM Rate Topic: -----

#1 thegreate  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-March 14

subtract the value in Column(listview)

Posted 25 March 2014 - 01:48 AM

I got error when the value in LOG_OUT is null :( is there anyway to subtract the 2 column in listview?




 Sub GetAttendace()



        'Purpose-to extract work assignment 
        Dim txtName As String = Form2.txtName.Text
        Dim dtpFrom As Date = Form2.dtpFromDate.Value
        Dim dtpTo As Date = Form2.dtpToDate.Value

        Dim ds As New DataSet
        Dim sql = "Select ID,SHIFT_DATE,AGENT_NAME,LOG_IN,LOG_OUT, cdate(LOG_OUT - LOG_IN)From tblAttendance Where AGENT_NAME like '" & txtName & "%' and SHIFT_DATE between #" & dtpFrom & "# and #" & dtpTo & "#"
        Dim LOGALL As String

        GetDataSet(sql, "WORK", ds)
  
        Dim lngWork As Long = ds.Tables("WORK").Rows.Count - 1
        Dim cWQ As Long = 0


        With Form2.ListView1
            .Items.Clear()
            If lngWork < 0 Then
                MessageBox.Show("There were no records found for the selected DATE or AGENT_NAME.")
                Exit Sub



            Else
                Do
                    Try

                        LOGALL = ds.Tables("WORK").Rows(cWQ).Item(5).ToString
                        Dim ID As String = ds.Tables("WORK").Rows(cWQ).Item(0).ToString
                        Dim SDATE As Date = ds.Tables("WORK").Rows(cWQ).Item(1).ToString
                        Dim ANAME As String = ds.Tables("WORK").Rows(cWQ).Item(2).ToString
                        Dim LogIN As Date = ds.Tables("WORK").Rows(cWQ).Item(3).ToString
                        Dim LogOUT As String = ds.Tables("WORK").Rows(cWQ).Item(4).ToString

                        Form2.ListView1.Items.Add(New ListViewItem(New String() _
                            {ID, SDATE, ANAME, LogIN, LogOUT, LOGALL}))
                    Catch ex As Exception

                    End Try

                    cWQ = cWQ + 1
                Loop Until cWQ > lngWork

            End If

        End With


    End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: subtract the value in Column(listview)

#2 deery5000  Icon User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Re: subtract the value in Column(listview)

Posted 25 March 2014 - 04:24 AM

Are you having the issue when attempting to add the details to the listview when the LOG_OUT value is null?
Was This Post Helpful? 0
  • +
  • -

#3 thegreate  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-March 14

Re: subtract the value in Column(listview)

Posted 25 March 2014 - 05:30 PM

YEH! I already convert it to string but still i got the error when the LOG_OUT is null :(
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1726
  • View blog
  • Posts: 5,704
  • Joined: 25-September 09

Re: subtract the value in Column(listview)

Posted 26 March 2014 - 05:24 AM

Assuming you're just looping through the rows and performing the math, you should just be able to use an If statement to ensure that you have valid information in the two columns so that the equation can be performed.

While Looping through the rows
  If NOT an invalid value in the column
    do math
  End if
End While

This post has been edited by CharlieMay: 26 March 2014 - 05:25 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1