Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 19:19

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C#]System.InvalidCastException

Discussion on [C#]System.InvalidCastException within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2011
Posts: 862
Received Thanks: 404
[C#]System.InvalidCastException

Hallo,
ich habe ein Porblem und keine Ahnung wie ich es lösen kann,
Ich habe als übung ein Rechner Programmiert der die Entfernung zweier Punkte
mittels GPS daten ermittelt.

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Geo_Rechner
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnRechnen_Click(object sender, EventArgs e)
        {
            double dLaengePosition1 = 0;
            double dBreitePosition1 = 0;
            double dLaengePosition2 = 0;
            double dBreitePosition2 = 0;
            double dDist = 0;

            dLaengePosition1 = Convert.ToDouble(tBoxP1L);
            dBreitePosition1 = Convert.ToDouble(tBoxP1B);
            dLaengePosition2 = Convert.ToDouble(tBoxP2L);
            dBreitePosition2 = Convert.ToDouble(tBoxP2B);

            dDist = 6378.388 * Math.Acos(Math.Sin(dBreitePosition1) * Math.Sin(dBreitePosition2) + Math.Cos(dBreitePosition1) * Math.Cos(dBreitePosition2) * Math.Cos(dLaengePosition2 - dLaengePosition1));

            lbAusgabe.Text += Convert.ToString(dDist);
            lbAusgabe.Text += " Kilometer.";
        }
    }
}
nur kommt es beim drücken auf den Button immer zur Fehlermeldung: System.InvalidCastException

Obwohl ich meines erachtens alles Korrekt gemacht hab.

Ich hoffe ihr könnt mir helfen

Mit freundlichen Grüßen,
Önte
Önte is offline  
Old 11/15/2014, 23:44   #2
 
YatoDev's Avatar
 
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
textbox.text eventuell? du kannst kein textbox objekt zu double umwandeln^^
YatoDev is offline  
Thanks
1 User
Old 11/23/2014, 01:43   #3
 
elite*gold: 22
Join Date: Feb 2012
Posts: 576
Received Thanks: 332
dLaengePosition1 = Convert.ToDouble(tBoxP1L); --> dLaengePosition1 = Convert.ToDouble(tBoxP1L.Text);
VisionEP1 is offline  
Reply


Similar Threads Similar Threads
[C#] error System.InvalidCastException
08/24/2013 - .NET Languages - 7 Replies
Hello! I was Coding a project wich connect and read something from sql database, MsSQL my = new MsSQL("select * from TableExample"); using (System.Data.SqlClient.SqlDataReader reader = my.Read()) { while (reader.Read()) { accInformation acc = new accInformation();



All times are GMT +2. The time now is 19:19.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.