The database class for CSectionSet, I define a pointer inside CSectionSet * m_pSet;
Then I want to get the sum of the six field values, displayed in the edit box, edit box ID for IDC_SUM,
How should write code?
I wrote the following code, using a button control:
void CSectionForm: : OnAvrcul ()
{
If (m_pSet - & gt; IsOpen ()) {
M_pSet - & gt; Close ();
}
M_pSet - & gt; The Open ();
Long a, [10].
Int I=0;
Long b=0;
M_pSet - & gt; MoveFirst ();
while(! M_pSet - & gt; IsEOF ())
{
A [I]=m_pSet - & gt; M_Value;
B +=a [I];
M_pSet - & gt; MoveNext ();
i++;
}
Cstrings c;
C.F ormat (" % d ", b);
SetDlgItemText (IDC_SUM, c);
}
Found displayed is the value of the currently selected item, rather than the sum, I put a [10] changed to a [2], it has six records, should be an error, but he is not an error, I felt there was no walk down recordset, cause there is only a number, so numerical display the selected item, how do I solve?
CodePudding user response:
No one help you, give a little adviceCodePudding user response:
This step you Debug mode order execution, look at the data correct?CodePudding user response:
According to the description should be each record has a sum (N) of a field, while the application is a N record fields andCodePudding user response: