Click here to Skip to main content
15,915,600 members
Home / Discussions / C#
   

C#

 
AnswerRe: Expiring app Pin
Tormod Fjeldskaar26-Jul-07 3:25
Tormod Fjeldskaar26-Jul-07 3:25 
Question.net 1.0 configuration for VS 2005 Pin
mercenary0125-Jul-07 23:20
mercenary0125-Jul-07 23:20 
AnswerRe: .net 1.0 configuration for VS 2005 Pin
Pete O'Hanlon26-Jul-07 0:28
mvePete O'Hanlon26-Jul-07 0:28 
GeneralRe: .net 1.0 configuration for VS 2005 Pin
mercenary0126-Jul-07 16:54
mercenary0126-Jul-07 16:54 
QuestionCreating collection classes and adding to property of control Pin
N a v a n e e t h25-Jul-07 22:57
N a v a n e e t h25-Jul-07 22:57 
AnswerRe: Creating collection classes and adding to property of control Pin
Urs Enzler25-Jul-07 23:10
Urs Enzler25-Jul-07 23:10 
GeneralRe: Creating collection classes and adding to property of control Pin
N a v a n e e t h25-Jul-07 23:26
N a v a n e e t h25-Jul-07 23:26 
QuestionHow can i solve this format exception Pin
xver25-Jul-07 22:52
xver25-Jul-07 22:52 
I receive a format exception message when i run this program.
the code is as follow:

string latitude1, latitude2;
string longitude1, longitude2;

latitude1 = label9.Text;
longitude1 = label10.Text;

label9.Text = textBox1.Text.ToString();
label10.Text = textBox2.Text.ToString();

latitude2 = label9.Text;
longitude2 = label10.Text;

if ((latitude1 != latitude2) || (longitude1 != longitude2))
{

double lat1 = Convert.ToDouble(latitude1);
double long1 = Convert.ToDouble(longitude1);
//double lat1 = 1.346094;
//double long1 = 103.932421266667;
double lat2 = Convert.ToDouble(latitude2);
double long2 = Convert.ToDouble(longitude2);

double lat1r = lat1 * (Math.PI / 180);
double long1r = long1 * (Math.PI / 180);
double lat2r = lat2 * (Math.PI / 180);
double long2r = long2 * (Math.PI / 180);

double latitude = lat2r - lat1r;
double longitude = long2r - long1r;

double a = Math.Pow(Math.Sin(latitude / 2.0), 2.0) + Math.Cos(lat1r) * Math.Cos(lat2r) * Math.Pow(Math.Sin(longitude / 2.0), 2.0);

double c = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1.0 - a));

const Double earthRadius = 6376.5;

distance = earthRadius * c;


}
totalDistance = totalDistance + distance;
label4.Text += totalDistance.ToString();

the exception came in at double lat1 = Convert.ToDouble(latitude1);
so i edited the code to:

string latitude1, latitude2;
string longitude1, longitude2;

latitude1 = label9.Text;
longitude1 = label10.Text;

label9.Text = textBox1.Text.ToString();
label10.Text = textBox2.Text.ToString();

latitude2 = label9.Text;
longitude2 = label10.Text;

if ((latitude1 != latitude2) || (longitude1 != longitude2))
{
if (latitude1!="" || longitude1!="")
{
double lat1 = Convert.ToDouble(latitude1);
double long1 = Convert.ToDouble(longitude1);
//double lat1 = 1.346094;
//double long1 = 103.932421266667;
double lat2 = Convert.ToDouble(latitude2);
double long2 = Convert.ToDouble(longitude2);

double lat1r = lat1 * (Math.PI / 180);
double long1r = long1 * (Math.PI / 180);
double lat2r = lat2 * (Math.PI / 180);
double long2r = long2 * (Math.PI / 180);

double latitude = lat2r - lat1r;
double longitude = long2r - long1r;

double a = Math.Pow(Math.Sin(latitude / 2.0), 2.0) + Math.Cos(lat1r) * Math.Cos(lat2r) * Math.Pow(Math.Sin(longitude / 2.0), 2.0);

double c = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1.0 - a));

const Double earthRadius = 6376.5;

distance = earthRadius * c;
}

}
totalDistance = totalDistance + distance;
label4.Text += totalDistance.ToString();

adding another if condition to solve the exception, although the format exception was handled. the end result of what was expected is not there. the totalDistance calculated show me an answer that display infinity.

any idea how i can solve this problem
AnswerRe: How can i solve this format exception [modified] Pin
Martin#25-Jul-07 23:01
Martin#25-Jul-07 23:01 
GeneralRe: How can i solve this format exception Pin
xver26-Jul-07 1:45
xver26-Jul-07 1:45 
GeneralRe: How can i solve this format exception Pin
Luc Pattyn26-Jul-07 6:48
sitebuilderLuc Pattyn26-Jul-07 6:48 
GeneralRe: How can i solve this format exception Pin
Peter Vertes1-Oct-07 10:32
Peter Vertes1-Oct-07 10:32 
QuestionProblem in reading data from any hardware device like Time access machine Pin
pathak7825-Jul-07 22:46
pathak7825-Jul-07 22:46 
QuestionGetting Address bar in FolderBrowserDialog Pin
Ankit Aneja25-Jul-07 22:35
Ankit Aneja25-Jul-07 22:35 
AnswerRe: Getting Address bar in FolderBrowserDialog Pin
Developer61126-Jul-07 0:14
Developer61126-Jul-07 0:14 
GeneralRe: Getting Address bar in FolderBrowserDialog Pin
Ankit Aneja26-Jul-07 2:50
Ankit Aneja26-Jul-07 2:50 
Questionhow to change directory in ftp using c#.net Pin
ironic2125-Jul-07 22:24
ironic2125-Jul-07 22:24 
QuestionDim WithEvents theCL As TOMListenerCall Pin
zinzineti25-Jul-07 22:06
zinzineti25-Jul-07 22:06 
AnswerRe: Dim WithEvents theCL As TOMListenerCall Pin
J4amieC25-Jul-07 22:15
J4amieC25-Jul-07 22:15 
GeneralRe: Dim WithEvents theCL As TOMListenerCall Pin
zinzineti25-Jul-07 22:35
zinzineti25-Jul-07 22:35 
GeneralRe: Dim WithEvents theCL As TOMListenerCall Pin
J4amieC25-Jul-07 23:41
J4amieC25-Jul-07 23:41 
Questionis there any way to keep an array listof points in an area? Pin
cyn825-Jul-07 21:45
cyn825-Jul-07 21:45 
GeneralThat's rude! Pin
Martin#25-Jul-07 22:02
Martin#25-Jul-07 22:02 
GeneralRe: That's rude! Pin
cyn825-Jul-07 22:19
cyn825-Jul-07 22:19 
JokeRe: That's rude! Pin
UglyxXXx25-Jul-07 23:08
UglyxXXx25-Jul-07 23:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.