Link to home
Start Free TrialLog in
Avatar of Mehram
MehramFlag for Pakistan

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

Avatar of Mehram
Mehram
Flag of Pakistan image

ASKER

Revised
--------

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
Avatar of Guy Hengel [angelIII / a3]
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
Avatar of Mehram

ASKER

Sir error is same.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mehram

ASKER

the total numbers of row is 69 and upon error move courser on dg its showing     dg.row = 9

Avatar of Mehram

ASKER

Is there any other way/logic to do this work
Avatar of Mehram

ASKER

Or is there any other control instead of datagrid which can use easly for the same purpose.
Avatar of vinnyd79
vinnyd79

Is the datagrid bound to a recordset or data control?