Smokeywade
Member
- Joined
- Sep 11, 2007
- Messages
- 22
- Programming Experience
- 3-5
ERROR - speciied argument was out of range parameter name: 7 is not valid for index.
I'm trying to calculate the time now minus time on a record and place that result in a column I created in the listview. It works fine when I try to place my results in a column thats on the database (which are 0 - 6)
When placing it in the column I created is when I get the parameter error - Code is below what am I missing...this works fine when using a datagrid...
'This is how I'm populating my listview
'Snippet of how I'm placing the results
Thanks - this is not the best way to do subtract date Time to get days not including sat and sunday - but its working - if anybody knows a better way - let me know that will be great.
I'm trying to calculate the time now minus time on a record and place that result in a column I created in the listview. It works fine when I try to place my results in a column thats on the database (which are 0 - 6)
When placing it in the column I created is when I get the parameter error - Code is below what am I missing...this works fine when using a datagrid...
'This is how I'm populating my listview
VB.NET:
DirAdapter.Fill(Mydataset3, "LateOrders_Header_view")
Dim dt As DataTable =
Mydataset3.Tables("LateOrders_Header_view")
Dim drow As DataRow
lstGrid.BeginUpdate()
lstGrid.Items.Clear()
For Each drow In Mydataset3.Tables("LateOrders_Header_view").Rows
Dim item As ListViewItem = New ListViewItem(drow("order_no").ToString)
item.SubItems.Add(drow("name").ToString)
item.SubItems.Add(drow("order_date").ToString)
item.SubItems.Add(drow("requested_date").ToString)
item.SubItems.Add(drow("reason").ToString)
item.SubItems.Add(drow("status").ToString)
item.SubItems.Add(drow("duedate").ToString)
lstGrid.Items.Add(item)
Next
fncDaysOpen()
' fncDaysLate()
lstGrid.EndUpdate()
'Snippet of how I'm placing the results
VB.NET:
For row = 0 To Mydataset3.Tables(0).Rows.Count - 1
Dim order_date As String
order_date = lstGrid.Items(row).SubItems(2).Text
Dim conv As DateTime
conv = System.Convert.ToDateTime(order_date)
Dim d1 As DateTime = conv
Dim d2 As DateTime = System.DateTime.Today
Dim subtract, absday
subtract = 0
Select Case DatePart("w", d1)
Case 1
subtract = subtract + 1
Case 7
subtract = subtract + 2
End Select
Select Case DatePart("w", d2)
Case 1
subtract = subtract + 2
Case 7
subtract = subtract + 1
End Select
absday = DateDiff("d", d1, d2) - 1
Dim x As String
x = absday - CInt(2 * (absday \ 7))
'Error occurs here when placing the results
lstGrid.Items(row).SubItems(7).Text = x
Thanks - this is not the best way to do subtract date Time to get days not including sat and sunday - but its working - if anybody knows a better way - let me know that will be great.
Last edited: