Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 105,754 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 1,780 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Displaying the current time 2 minutes ahead.

 
Reply to this topicStart new topic

Displaying the current time 2 minutes ahead.

jpool
post 2 Jul, 2008 - 07:14 AM
Post #1


New D.I.C Head

*
Joined: 22 Jan, 2008
Posts: 8

Hi, i have the following code that relates to a simple label:

CODE
Label1.Text = DateAdd("n", 2, DateAdd("h", 0, Trim(Format(Now, "HH:mm"))))


It displays the current time 2 minutes ahead of time, but even though i have specified the time format as Hours and Minutes, it still displays the 'seconds' on the Form Label.

Is there anyway i can make it only show the time in Hours and Minutes?

Thanks,
Julian
User is offlineProfile CardPM

Go to the top of the page


AdamSpeight2008
post 2 Jul, 2008 - 08:02 AM
Post #2


D.I.C Regular

Group Icon
Joined: 29 May, 2008
Posts: 476



Thanked 31 times

Dream Kudos: 1800
My Contributions


QUOTE(jpool @ 2 Jul, 2008 - 03:14 PM) *

Hi, i have the following code that relates to a simple label:

CODE
Label1.Text = DateAdd("n", 2, DateAdd("h", 0, Trim(Format(Now, "HH:mm"))))


It displays the current time 2 minutes ahead of time, but even though i have specified the time format as Hours and Minutes, it still displays the 'seconds' on the Form Label.

Is there anyway i can make it only show the time in Hours and Minutes?

Thanks,
Julian


If this is for vb6 then
VB

Label1.Caption=Format(DateAdd("n", 2, Now), "HH:mm")

else if its vb.net (which is suggested by using .text on a label)
VB

Label1.Text= DateAdd(DateInterval.Minute, 2, Now).ToString("HH:MM")

User is offlineProfile CardPM

Go to the top of the page

jpool
post 2 Jul, 2008 - 08:49 AM
Post #3


New D.I.C Head

*
Joined: 22 Jan, 2008
Posts: 8

Ah, perfect.

It was for 2005, but works a treat. Although needed to change the 'MM' to 'mm' (lowercase).

Thanks smile.gif
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 2 Jul, 2008 - 09:01 AM
Post #4


D.I.C Regular

Group Icon
Joined: 29 May, 2008
Posts: 476



Thanked 31 times

Dream Kudos: 1800
My Contributions


QUOTE(jpool @ 2 Jul, 2008 - 04:49 PM) *

Ah, perfect.

It was for 2005, but works a treat. Although needed to change the 'MM' to 'mm' (lowercase).

Thanks smile.gif

You're welcome.
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 2 Jul, 2008 - 09:06 AM
Post #5


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,028



Thanked 47 times

Dream Kudos: 7600

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI

My Contributions


Moved to VB.NET

Thanks for the nice reply Adam smile.gif
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/21/08 12:20PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month