“遇到不正当的论点"; [英] "Encountered an improper argument"

查看:99
本文介绍了“遇到不正当的论点";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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.


这篇关于“遇到不正当的论点";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆