Mehram
asked on
VB 6 Datagrid Control
I am using datagrid control on my form and using following statement on button click.
AA = ""
For i = 0 To DG2.ApproxCount - 1
DG2.Row = i
If CLng(DG2.Columns(4).Text) > 0 Then
AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
End If
Next
AA = AA + TxtNaration.Text
It is working properly but in the last row it is showing following error:
RUN TIME ERRO '6148'
INVALID ROW NUMBER
Please help how to resolve this problem.
Rgds.
Mehram
AA = ""
For i = 0 To DG2.ApproxCount - 1
DG2.Row = i
If CLng(DG2.Columns(4).Text) > 0 Then
AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
End If
Next
AA = AA + TxtNaration.Text
It is working properly but in the last row it is showing following error:
RUN TIME ERRO '6148'
INVALID ROW NUMBER
Please help how to resolve this problem.
Rgds.
Mehram
please try this:
AA = ""
For i = 0 To DG2.ApproxCount - 2
DG2.Row = i
If CLng(DG2.Columns(4).Text) > 0 Then
AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
End If
Next
AA = AA + TxtNaration.Text
AA = ""
For i = 0 To DG2.ApproxCount - 2
DG2.Row = i
If CLng(DG2.Columns(4).Text) > 0 Then
AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
End If
Next
AA = AA + TxtNaration.Text
ASKER
Sir error is same.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the total numbers of row is 69 and upon error move courser on dg its showing dg.row = 9
ASKER
Is there any other way/logic to do this work
ASKER
Or is there any other control instead of datagrid which can use easly for the same purpose.
Is the datagrid bound to a recordset or data control?
ASKER
--------
I am using datagrid control on my form and using following statement on button click.
AA = ""
For i = 0 To DG2.ApproxCount - 1
DG2.Row = i
If CLng(DG2.Columns(4).Text) > 0 Then
AA = AA + DG2.Columns(0).Text + "-" + " Code: " + DG2.Columns(1).Text + " Head: " + DG2.Columns(2).Text + " Amount: " + DG2.Columns(4).Text + ", "
End If
Next
AA = AA + TxtNaration.Text
It is working properly but in the last row it is showing following error:
Error Line ===>>> DG2.Row = i
RUN TIME ERRO '6148'
INVALID ROW NUMBER
Please help how to resolve this problem.
Rgds.
Mehram