VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 300,404 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,616 people online right now. Registration is fast and FREE... Join Now!




time calculation

 

time calculation

bane_kis

18 Jun, 2009 - 05:37 PM
Post #1

New D.I.C Head
*

Joined: 18 Jun, 2009
Posts: 2

Hi everyone

I calculated what time is needed for some operation and my result is in minutes. Question is how to add those minutes to current time/date?


User is offlineProfile CardPM
+Quote Post


June7

RE: Time Calculation

18 Jun, 2009 - 06:23 PM
Post #2

D.I.C Regular
Group Icon

Joined: 9 Dec, 2008
Posts: 476



Thanked: 37 times
My Contributions
Check out DateAdd function
http://msdn.microsoft.com/en-us/library/hcxe65wz(VS.80).aspx
User is offlineProfile CardPM
+Quote Post

bane_kis

RE: Time Calculation

18 Jun, 2009 - 07:09 PM
Post #3

New D.I.C Head
*

Joined: 18 Jun, 2009
Posts: 2

Thank you very much
User is offlineProfile CardPM
+Quote Post

forsagar

RE: Time Calculation

29 Jun, 2009 - 02:23 AM
Post #4

New D.I.C Head
*

Joined: 28 Jun, 2009
Posts: 1


My Contributions
cool.gif looks like work done using just left hand biggrin.gif
Use this code to calculate time icon_up.gif

first of all you need 2 dtpicker
add it using this components--> microsoft windows common control 2 6.0

change datepicker's format to 2-dtptime from property window


if you want to calculate time by current time then you need a timer so add it and change it's interval to 1000

now add 3 labels to display hour,minute and second separately of your calculation

then

change it's name to lblhour,lblmin and lblsec respectively

now this code will work perfactly........ wink2.gif biggrin.gif smile.gif cool.gif

CODE

Dim d1, d2 As Date

Private Sub DTPicker1_Change()
    d1 = Format(DTPicker1.Value, "hh:mm:ss")
    d2 = Format(DTPicker2.Value, "hh:mm:ss")
    lblhour.Caption = DateDiff("h", d1, d2)    
    lblmin.Caption = DateDiff("n", d1, d2)
    lblsec.Caption = DateDiff("s", d1, d2)

End Sub

Private Sub Timer1_Timer()
        dtp2.Value = Time        'This will change datepicker's value to current time in every second automatic
End Sub


In this if you don't want to calculate time from current time
do not use timer
use a command button and write this code in it's click event

command button's name = cmdcalculate rolleyes.gif


CODE


Dim d1, d2 As Date

Private Sub cmdcalculate_Click()
    d1 = Format(DTPicker1.Value, "hh:mm:ss")
    d2 = Format(DTPicker2.Value, "hh:mm:ss")
    lblhour.Caption = DateDiff("h", d1, d2)
    lblmin.Caption = DateDiff("n", d1, d2)
    lblsec.Caption = DateDiff("s", d1, d2)
End Sub



dream.in.code is a best forum site for vb
This is my first post on this site

If this post= usefull to you Then
click on "This post was helpful !"
Else
click on "reply"
End If smile.gif biggrin.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:34PM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month