Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i need help in an operation
after i ve got totals of' hour and minutes
i did ( moneytotal = Price * Hours) so as to get total of money,
code:
C#
DGTotalMoney.DigitText = (double.Parse(DGHours.DigitText) * (double.Parse(CBlistPrice.Text))).ToString();

but i need to count minutes too and add it to hours
Posted
Comments
Sushil Mate 25-Jun-13 1:21am    
can you elaborate more? i think solution 1 will work for your scenario. try to explain by example.
Atif BOUZAGLAOUI 25-Jun-13 1:35am    
now i got A label in it 40 hours and another label in it 30 minutes;
so what the operation shall i do so as to get the total of money
i did this code but ithe total is not right:
DGTotalMoney.DigitText = (((double.Parse(DGHours.DigitText)) + (double.Parse(DGMinutes.DigitText) / 60)) * (double.Parse(CBlistPrice.Text))).ToString();

@Atif Try below function to convert time to 100 format.

C#
protected double ConvertTo100(string strTemp)
        {
            strTemp = strTemp.Replace(':', '.');
            
            double dblTemp;
            dblTemp = Convert.ToDouble(strTemp);

            double dblHH = Math.Floor(dblTemp);
            double dblMM = Math.Round(dblTemp - Math.Floor(dblTemp), 2) * 60 / 100;

            double dboReturn;
            dboReturn = dblHH + dblMM;
            return dboReturn;
        }

than you can use this funcation like..
C#
DGTotalMoney.DigitText = Convert.ToString(ConvertTo100("Your time here in HH:MM format") * (double.Parse("Your Price Here")));
 
Share this answer
 
Comments
Atif BOUZAGLAOUI 25-Jun-13 2:40am    
i got hours and minutes in two labels how can i put like this HH:MM
is is like that
DGTotalMoney.DigitText = Convert.ToString(ConvertTo100("DGHours.DigitText:DGMinutes.DigitText") * (double.Parse("CBlistPrice.Text")));
KiranKumar Roy 25-Jun-13 2:48am    
you can use it like below..

DGTotalMoney.DigitText = Convert.ToString("YOUR MINUTE'S LABLE TEXT") + ":" + Convert.ToString("YOUR SECOND'S LABLE TEXT");
Atif BOUZAGLAOUI 25-Jun-13 3:08am    
i use it like this but it did not give the right total of money : DGTotalMoney.DigitText = Convert.ToString(ConvertTo100(DGHours.DigitText) + ":" + Convert.ToString(ConvertTo100(DGMinutes.DigitText) * (double.Parse(CBlistPrice.Text))));
anyway thank you brother
KiranKumar Roy 25-Jun-13 4:48am    
You have to write like below..
DGTotalMoney.DigitText = Convert.ToString( ConvertTo100(DGHours.DigitText + ":" + DGMinutes.DigitText) * (double.Parse(CBlistPrice.Text));
Atif BOUZAGLAOUI 25-Jun-13 23:16pm    
yes brother kiran the code working but it does not give me right result as calculator
i tried this code ;
DGTotalMoney.DigitText = ((double.Parse(DGHours.DigitText) + double.Parse(DGMinutes.DigitText)/60 )* (double.Parse(CBlistPrice.Text))).ToString();
and your code too, i don`t know why iam confused
C#
DGTotalMoney.DigitText = (double.Parse(DGHours.DigitText + (DGMinutes.DigitText / 60)) * (double.Parse(CBlistPrice.Text))).ToString();


Hope this is what you wanted.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900