Input string was not in a correct format, “double.parse(textbox.text);”

后端 未结 4 1145
栀梦
栀梦 2021-01-28 10:45

Hi am quite new to visual studios.

This is my code so far to make an example of an atm, i have a text box and i put an amount in and then i have this button where i clic

4条回答
  •  不思量自难忘°
    2021-01-28 11:37

    String in textboxamount.Text can not be parsed as double. To avoid exception you can use double.TryParse instead.

    double amount;
    
    if(double.TryParse(textboxamount.Text, out amount))
    {
        totalamount += amount;
    }
    

    Also, label2 seems to be Label and you must use

    label2.Text = balance1 + totalamount;
    

    instead.

提交回复
热议问题