Jump to content

System.FormatException: 'Cadeia de caracteres de entrada com formato incorreto.'


Recommended Posts

Boas a todos, quando eu ponho um dos meus programas a executar aparece este erro, mas eu não o consigo entender.

System.FormatException: 'Cadeia de caracteres de entrada com formato incorrecto.'

This exception was originally thrown at this call stack:
    [External Code]
    WindowsFormsApplication3.Form1.button1_Click_1(object, System.EventArgs) in Form1.cs
    [External Code]
    WindowsFormsApplication3.Program.Main() in Program.cs

Segue abaixo parte do código.

Alguém me pode ajudar, por favor?


double total = 0;
            double hst = 0;
            double totaldue = 0;

            foreach (ListViewItem item in listView1.Items)
                total += Convert.ToDouble(item.SubItems[2].Text);

            hst = total * 0.13;
            totaldue = hst + total;

            string hstDisplay = hst.ToString("c2");
            string totalDisplay = totaldue.ToString("c2");
            string amount = total.ToString("c2");
            textBox8.Text = amount;
            textBox9.Text = hstDisplay;
            textBox10.Text = totalDisplay;



Link to comment
Share on other sites

Sem mais informação - o log de erro deve ter bem mais informação do que o que metes ai - diria que é essa conversão para double que está a dar o problema.

10 REM Generation 48K!
20 INPUT "URL:", A$
30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50
40 PRINT "404 Not Found"
50 PRINT "./M6 @ Portugal a Programar."


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.