“遇到不正当的论点";

问题描述:

这可能是什么问题?工作正常,然后...不正确的参数.

它与删除数组中的记录有关吗?

What could be wrong with this? It was working fine and then...Improper Argument.

Could it have something to do with deleting records from the array?

for(int i = 0; i < FirstName.GetCount(); i++)
    {
        nItem = m_ListCtrl.InsertItem(0, FirstName[i] + L" " + LastName[i]);
        for(int j = 0; j < 8; j++)
        {
            if(Item[numItems].IsEmpty() == FALSE)
            {
            nItem = m_ListCtrl.InsertItem(1, L"");
            m_ListCtrl.SetItemText(nItem, 1, Item[numItems]);
            m_ListCtrl.SetItemText(nItem, 2, Quantity[numItems]);
            m_ListCtrl.SetItemText(nItem, 3, Cost[numItems]);
            m_ListCtrl.SetItemText(nItem, 4, Price[numItems]);
            m_ListCtrl.SetItemText(nItem, 5, Profits[numItems]);
            }
            numItems++;
        }
    }

您最好的朋友就是大多数情况下的调试器.但是仅仅看代码我会怀疑
Your best friend is as in most cases your debugger. But from just looking at the code I would suspect that
nItem = m_ListCtrl.InsertItem(0, FirstName[i] + L" " + LastName[i]);


可能由于失败(无论出于何种原因)而返回-1,并且以下


might return -1 when not successful (for whatever reason) and the following

m_ListCtrl.SetItemText(nItem, 1, Item[numItems]);



将失败,因为nItem为-1.



will fail because nItem is -1.


我试图读取超出数组存储数据量的数组.这是我为解决此问题所做的事情:

I was trying to read my arrays beyond the amount of data that the arrays had stored. This is what I did to fix this issue:

s7 = (((_wtof(myData[nPos].m_sPrice7) / _wtof(myData[nPos].m_sQty7)) - _wtof(myData[nPos].m_sCost7)) * _wtof(myData[nPos].m_sQty7));
            t7.Format(L"%.2f", s7);
            if(s7 > 0)
                dlg.Profits.Add(t7);
            else
                dlg.Profits.Add(L"0");



我添加了else语句来解决我的问题,它又可以正常工作.



I added the else statement to fix my problem, it works fine again.