Solved

How would I split a number at the decimal and put the two values in separate variables

Posted on 2013-01-28
3
288 Views
Last Modified: 2013-01-28
Examples:  I get a return value of   49.85  I need to put the 49 in var1 and the  .85 in var2.  Ho do  i programmaticly split the values into the two variables?

Thank you
0
Comment
Question by:bmanmike39
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 38829370
double start = 49.85;
double whole = Math.Truncate(start);
double fract = start - whole;

Open in new window

0
 
LVL 7

Expert Comment

by:Element1910
ID: 38829374
In your code behind try this (and for example purposes I'll be using a Label (named Label1" that will be displaying your 49.85):
string s = Label1.Text.ToString();
            string[] parts = s.Split('.');
            int var1 = int.Parse(parts[0]);
            int var2 = int.Parse(parts[1]);

Open in new window

0
 

Author Closing Comment

by:bmanmike39
ID: 38829481
Thanks it works.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question