Solved

How do I add minutes to a specific time in c#.net?

Posted on 2008-10-15
2
1,173 Views
Last Modified: 2013-12-17
I have a text box  that will populate with the current time when you click inside the text box example(6:40pm). I have another text box that users will enter just a number to represent minutes example (30). I have another text box that I want to display the time after adding the minutes entered to the current time.

EXAMPLE 6:40pm + 30 = 7:10pm
0
Comment
Question by:wademi
2 Comments
 
LVL 16

Expert Comment

by:CuteBug
ID: 22727146
Convert the value in the first textbox to DateTime object.
And then call the AddMinutes() method of that object with the data in the second textbox as argument.
0
 
LVL 6

Accepted Solution

by:
carlsiy earned 500 total points
ID: 22727158
Provided that you have 3 TextBoxes.
textBox1 = Current Time
textBox2 = Amount of minutes to be added
textBox3 = Output of textBox1 + textBox2

        private void button4_Click(object sender, EventArgs e)
        {
            textBox3.Text = DateTime.Parse(textBox1.Text).AddMinutes(double.Parse(textBox2.Text)).ToShortTimeString();
        }
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Regular expression help 2 35
C#.net split string and then check appropriate checkboxlist 4 27
MYSQL responding very slow 3 23
Groupbox Control ? 2 18
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

838 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