TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
matthew king
NA
52
0
Rounding a value in a textbox field (Math.Round)
Aug 22 2009 9:12 PM
Hey experts. I've been working on a code to determine the distance between two long and lat coordinates. I was able to get it to work. I thought that was going to be the hard part, but I was wrong. I figured that out, but haven't been able to determine how to round the value of result.Text to the next whole number. Can you assist me with the Math.Round class? Again, I'm trying to round the value obtained in the result.Text textbox. private void button3_Click(object sender, EventArgs e) { string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(@"c:\test.txt"); while ((line = file.ReadLine()) != null) { Console.WriteLine(line); string[] lineStrings = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (lineStrings.Length > 3) { if (lineStrings[0] == dep.Text) { p1x.Text = lineStrings[2]; p2x.Text = lineStrings[1]; // Suspend the screen.Console.ReadLine();} Console.ReadLine(); // Read the file and display it line by line. System.IO.StreamReader file2 = new System.IO.StreamReader(@"c:\nav.txt"); while ((line = file2.ReadLine()) != null) { Console.WriteLine(line); string[] lineStrings1 = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (lineStrings1.Length > 3) { if (lineStrings1[0] == textBox1.Text) { p1y.Text = lineStrings1[2]; p2y.Text = lineStrings1[1]; ; double rad = 3440; double p1X = Convert.ToDouble(p1x.Text) / 180 * Math.PI; double p1Y = Convert.ToDouble(p2x.Text) / 180 * Math.PI; double p2X = Convert.ToDouble(p1y.Text) / 180 * Math.PI; double p2Y = Convert.ToDouble(p2y.Text) / 180 * Math.PI; //need to round this result.Text textbox???? result.Text = Convert.ToString(Math.Acos(Math.Sin(p1Y) * Math.Sin(p2Y) + Math.Cos(p1Y) * Math.Cos(p2Y) * Math.Cos(p2X - p1X)) * rad);
Reply
Answers (
2
)
Passing parameters to a running winxp service using command line
get remote username, OS version!