-
how to count the total rows in datagrid
hi,
please help..
i need to know how to count the total rows in datagrid. only i was able to determine how to determine the total columns (datagrid1.columns.count). Can anyone would help me?
thanks n advance..
relan
-
Is the DataGrid bound to a recordset? If so, the number of rows is equal to the recordset's .RecordCount property.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
phil webber,
thanks a lot for helping me. Also i will ask again a favor from you.
Now i get the total row count in datagrid. For example i have 17 rows and each row have 18 columns with values on each. how do i read all the values in each rows.
by the way this is my code in reading the values in each rows but i get an error when i reach reading at row 15.
thanks in advance and god bless..
--------------------------------------------------------------------------
Private Sub Command1_Click()
Dim date_sub As String, computer As String, printer As String, username As String, document As String
Dim status As String, pages As String, bytes As String
Dim total_rows As String
Dim i As Integer
total_rows = Read_Text_File.RecordCount
For i = 0 To total_rows
dgdata.row = i
dgdata.Col = 8
date_sub = dgdata.Text
dgdata.row = i
dgdata.Col = 2
computer = dgdata.Text
dgdata.row = i
dgdata.Col = 1
printer = dgdata.Text
dgdata.row = i
dgdata.Col = 3
username = dgdata.Text
dgdata.row = i
dgdata.Col = 4
document = dgdata.Text
dgdata.row = i
dgdata.Col = 13
status = dgdata.Text
dgdata.row = i
dgdata.Col = 5
pages = dgdata.Text
dgdata.row = i
dgdata.Col = 9
bytes = dgdata.Text
If pages = "0" Then
pages = "unknown"
End If
MsgBox date_sub & ": " & computer & ": " & printer & ": " & username & ": " & document & ": " & status & ": " & pages & ": " & bytes
Next
End Sub
--------------------------------------------------------------------------
-
What data type is Read_Text_File? If it's a recordset, you can (and should) read the data values from it, rather than from the grid. The recordset contains the data; the grid is only to display it.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
debug.print DataGrid1.ApproxCount
This would display the row count of the Datagrid1
-
The Grid's Row method is 0 based. So the last Row is Recordcount -1
Therefore use: For i = 0 To (total_rows -1)
(Also, never use the ApproxCount for something like this. As the name says: It is an approximate count, and may not always be the actual count with large recordsets.)
 Originally Posted by relan8
phil webber,
thanks a lot for helping me. Also i will ask again a favor from you.
Now i get the total row count in datagrid. For example i have 17 rows and each row have 18 columns with values on each. how do i read all the values in each rows.
by the way this is my code in reading the values in each rows but i get an error when i reach reading at row 15.
thanks in advance and god bless..
--------------------------------------------------------------------------
Private Sub Command1_Click()
Dim date_sub As String, computer As String, printer As String, username As String, document As String
Dim status As String, pages As String, bytes As String
Dim total_rows As String
Dim i As Integer
total_rows = Read_Text_File.RecordCount
For i = 0 To total_rows
dgdata.row = i
dgdata.Col = 8
date_sub = dgdata.Text
dgdata.row = i
dgdata.Col = 2
computer = dgdata.Text
dgdata.row = i
dgdata.Col = 1
printer = dgdata.Text
dgdata.row = i
dgdata.Col = 3
username = dgdata.Text
dgdata.row = i
dgdata.Col = 4
document = dgdata.Text
dgdata.row = i
dgdata.Col = 13
status = dgdata.Text
dgdata.row = i
dgdata.Col = 5
pages = dgdata.Text
dgdata.row = i
dgdata.Col = 9
bytes = dgdata.Text
If pages = "0" Then
pages = "unknown"
End If
MsgBox date_sub & ": " & computer & ": " & printer & ": " & username & ": " & document & ": " & status & ": " & pages & ": " & bytes
Next
End Sub
--------------------------------------------------------------------------
Similar Threads
-
By software_develo in forum .NET
Replies: 0
Last Post: 01-01-2006, 11:24 PM
-
By software_develo in forum .NET
Replies: 1
Last Post: 12-27-2005, 06:28 AM
-
By barbarosa80503 in forum VB Classic
Replies: 2
Last Post: 10-28-2005, 03:33 PM
-
By Michael L in forum VB Classic
Replies: 2
Last Post: 11-17-2000, 03:18 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|