小编Mar*_*rko的帖子

C#Windows窗体 - 从局部变量中分配textBox值(数值)

对于插入textBox2中的数量,此方法正在减小textBox1的值.如果textBox1中没有足够的"钱",则应从textBox3中获取超额金额.最后,方法应该将文本框更新为新值,但只清除textBox2,textBox1和textBox3保持不变.任何人都可以告诉我为什么textBox1.text = Account.toString()不将文本框值赋值给变量值Account并且textBox3.text = Savings.toString()不将文本框值赋值给变量值Savings

public void Debit(decimal amount)
    {
        decimal Account = Convert.ToDecimal(textBox1.Text);
        decimal Savings = Convert.ToDecimal(textBox3.Text);

        if ((Account + Savings) < amount)
            if (Overdrawn != null)
                Owerdrawn(this, new OverdrawnEventArgs (Account, amount));
        else if (Account >= amount)
            Account -= amount;
        else {
            amount -= Account;
            Account = 0m;
            Savings -= amount;
        }
        textBox1.Text = Account.ToString();
        textBox2.Clear();
        textBox3.Text = Savings.ToString();
    }
Run Code Online (Sandbox Code Playgroud)

.net c# textbox winforms

2
推荐指数
1
解决办法
9613
查看次数

标签 统计

.net ×1

c# ×1

textbox ×1

winforms ×1