读书人

请大家帮小弟我解决一个小疑点.

发布时间: 2012-02-10 21:27:42 作者: rapoo

请大家帮我解决一个小问题...
private void Form1_Load(object sender, EventArgs e)
{
double m_dBaseMoneyGive = 0.0;
double m_dBaseMoneyLeave = 0.0;
double m_dMoneyInterestGive = 0.0;
double m_dTotalMoneyGive = 0.0;
double m_dYearInterestRate = 0.0;
double m_dMonthMoneyGive = 0.0;
int m_nMonthNum = 0;
int m_nMoneyGiveType = 0;
long m_lTotalMoney = 0;
}

.......


private void button1_Click(object sender, EventArgs e)
{

// 贷款总数Check
if (m_lTotalMoney <= 0)
//vs2005说:
//The name 'm_lTotalMoney 'does not exist in the current context


{
MessageBox.Show( "[贷款总数]输入不正确 ");
}

// 年利率Check


if (comboBox1.Text.Length==0 )
{
MessageBox.Show( "请输[年利率] ");
}
}

请帮我解决一下这是个什么问题,谢谢了

[解决办法]
变量m_lTotalMoney 只在load函数中起作用,要作为全局变量,而且从你写的代码来看,m_lTotalMoney 始终等于0

[解决办法]
//在类里面定义


double m_dBaseMoneyGive = 0.0;
double m_dBaseMoneyLeave = 0.0;
double m_dMoneyInterestGive = 0.0;
double m_dTotalMoneyGive = 0.0;
double m_dYearInterestRate = 0.0;
double m_dMonthMoneyGive = 0.0;
int m_nMonthNum = 0;
int m_nMoneyGiveType = 0;
long m_lTotalMoney = 0;

private void Form1_Load(object sender, EventArgs e)
{
}

private void button1_Click(object sender, EventArgs e)
{

// 贷款总数Check
if (m_lTotalMoney <= 0)
{
MessageBox.Show( "[贷款总数]输入不正确 ");
}

// 年利率Check


if (comboBox1.Text.Length==0 )
{
MessageBox.Show( "请输[年利率] ");
}
}

[解决办法]
To:我在生成的程序中的代款总数输入5000后,点击button1为什么还显示 "[贷款总数]输入不正确 "呢?? 是不是有什么地方是要连接的???

m_lTotalMoney的值是怎么赋的?

如果没有赋值 那么
if (m_lTotalMoney <= 0)
{
MessageBox.Show( "[贷款总数]输入不正确 ");
}
将永远成立


读书人网 >C#

热点推荐