DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   I'm an apprentice.Please (http://www.daniweb.com/forums/thread76057.html)

Randika Apr 21st, 2007 2:14 pm
I'm an apprentice.Please
 
I'm an aprentice to VB,but have a little knowledge and interested in doing experiments.
What i want to know is,how to get the time difference?
text1.text includes the 1st updated time and text2.text includes the 2nd updated time.text3.text must be the difference between two times.
please teach me to do this.

scudzilla Apr 21st, 2007 3:47 pm
Re: I'm an apprentice.Please
 
Perhaps you can use Hour(Time), Minute(Time), and Second(Time) to get the hour, minute and second respectively for each of the two time points.

aparnesh Apr 21st, 2007 3:48 pm
Re: I'm an apprentice.Please
 
Use the datediff function.

TimeDiff = DateDiff("n", Time1, Time2)

will give the time difference in minutes. For difference in seconds, use "s" instead of "n". Look up the datediff function in the Help files to see the syntax and various parameter options

jbennet Apr 21st, 2007 3:51 pm
Re: I'm an apprentice.Please
 
in vb you can get the current time by using now()

venkatramasamy Oct 31st, 2007 3:38 am
Re: I'm an apprentice.Please
 
HI

you need to set the Time Difff in text3 control right, then use the following code under any event

text3.text=DateDiff("n",cdate(text1.text),cdate(text2.text)

it is suggeted to check for the valid time entry by using the isdate function
Ex:
if isdate(text1.text)=false then
msgbox "Not Valid Time"

end if

hope this will help you,

regards
Venkatramasamy Sn


All times are GMT -4. The time now is 2:48 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC