473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"Add 5 minutes to current time which is in string"

Hi, I have taken two textboxes, 1 shows the current time i.e system time, while in other textbox, I want to show five minutes added to the system time. How to do that?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Arrival_timeTextBox_TextChanged(sender As Object, e As EventArgs) Handles Arrival_timeTextBox.TextChanged
  2.  
  3.         Arrival_timeTextBox.Text = DateTime.Now.ToLongTimeString()
  4.     End Sub
  5.  
  6.     Private Sub DepartureTextBox_TextChanged(sender As Object, e As EventArgs) Handles DepartureTextBox.TextChanged
  7.  
  8. ??
  9.  
  10.     End Sub
  11. End Class
Feb 1 '15 #1
2 5371
IronRazer
83 64KB
Hi,

You most likely are not going to want to set the textbox`s text inside the same textbox`s TextChanged event. Depending on what you are doing it may cause an infinite loop.

You will want to use a Date variable to assign the current date to and display that in one textbox. Then you can use the Date.AddMinutes method to add 5 minutes to that date. Then display that in the other textbox.

Here is an example:
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim CurrentDate As Date = Now
  3.         Arrival_timeTextBox.Text = CurrentDate.ToLongTimeString()
  4.  
  5.         Dim FiveMinutesAdded As Date = CurrentDate.AddMinutes(5)
  6.         DepartureTextBox.Text = FiveMinutesAdded.ToLongTimeString
  7.     End Sub
  8.  
Feb 1 '15 #2
Frinavale
9,735 Expert Mod 8TB
Use one of the DateTime.TryParse methods to retrieve the date out of the text box and convert it into a DateTime type.

Once you have converted/parsed the string into a DateTime type you can use the methods like the AddMinutes Method to do what you want.

-Frinny
Feb 3 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Chris | last post by:
Sorry, This should be simple, but brain is hurting... How do I convert a Current Time to a Decimal 6,0 (HMS)? There must be a cleaner way then this: Insert into Table Values Dec(...
2
by: MarthaR | last post by:
I am trying to add the current time to a field when the user clicks on the toggle button next to the field. I am getting a time of 12:00:00 AM each time I click the button. How do I get a...
18
by: Tim Quon | last post by:
Hi I need to print the current time. I found an example where this is done as followed: long *mytime; time(mytime); printf("time: %s", ascitime(mytime); But this doesn't work and prints...
3
by: | last post by:
I have a datetime field in table. I want to insert the current time of database server to the table thr ASP.NET (C#). I have dataset to do the insert: DataSet1.TableNameRow rowNew =...
7
by: mekim | last post by:
Hi All, is there a webservice for get the current time? I am looking to get the current time via a webservice and then set the time of the server. Regards, Mekim
4
by: Gary Wessle | last post by:
Hi I am not getting current time with this program, what am I doing wrong? #include <ctime> #include <iostream> using namespace std; #define P(x) cout << #x " = " << (x) << "\n";
0
by: Saloni | last post by:
I have windows service which is going to run on several machines which are in different time zones in USA. I want to find out the Eastern Zone current time from these different machines. It...
3
by: Mark Ingram | last post by:
Hi, I'd like to know the best way of checking the current time during a demonstration product. At the minute i store the first run date, then compare that to the system time, but obviously a user...
4
by: iwdu15 | last post by:
Hi, in VB i could use the keyword Now to get the current DateTime, but C# doesnt have that. How can i get the current time? thanks -- -iwdu15
2
Rozeanna Jerry
by: Rozeanna Jerry | last post by:
Hi every one..I am trying to add 8 hours 15 minutes to current time and show the new time on a text box. How would I do that.? For example if the current time is 8:00am then adding 8 hours 15...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.