time in vb

  • Thread starter Thread starter giorgio
  • Start date Start date
G

giorgio

How can i write the time in vb ?
ex txtText1 '"< 1 hour 12 minutes 5 seconds "< 1:12:05 txtText1 =
'"between 0 hour 05 minutes 5 seconds and 0 hour 07 minutes 5 seconds"
between 0:05:05 and 0:07:05

thx
 
Hi Giorgio,

Use the DateDiff function to calculate the difference between two dates
and/or times or break the time into its constituent parts (hours, minutes
and seconds) and compare each value.

HTH
Martin
 
It isn't a calculation.
my condition is time: hour, minutes, second or minutes, seconds
If condition then
ctr.FormatConditions(0).Backcolor=XYZ
elseif condizione then
ctr.formatconditions(0).backcolor=YZS
else
.....
endif
 
If (Me.txtText1 >= # 00:05:05#) AND (Me.txtText1 <= #00:07"05#) Then
...
 
But what is your 'condition'? If it's something similar to :

if x > lowerlimittime and x < upperlimittime then
do something
else
do something else
endif

...then you need to do some calculation to get everything into the same
'units'. VB can't do straight time calculations, hence the functions such as
DateDiff, DateAdd, DatePart etc.

Martin
 
My problem is : when i type #00:05:05# ms vb change it in #12:05:05 AM#
what imust i make ?

thx
 
The problem you're running into is that Access doesn't do "times". It deals
with a date and a time during that date, but if you want to enter something
such as a song runs 3 minutes and 23 seconds, that is not considered a
"time". A Date/Time value is a particular point in time. The example is an
elapsed time. You will need to break it apart on the delimiter, in this case
the colon, multiply the first part by 3600, the second by 60, and add all
three together to get the value in seconds then use that value for your
formatting. It may be easier to create three different fields, place the
boxes next to each other on the form with a label between them that has the
colon. Format the label and boxes to look the same and set them so close
that you can't see the boundary between them. You may also want to use the
Auto Tab property of the textboxes so that you don't have to press the tab
key go move between them.
 
My problem is : when i type #00:05:05# ms vb change it in #12:05:05 AM#
what imust i make ?

None. Those are two different ways of depicting the same time. Your
criterion will work fine.

A Date/Time field in Access is a Double Float count of days and
fractions of a day since midnight, December 30, 1899. That value is
stored as 3.53009259259259E-03 and corresponds to a time on that
long-ago day.

If you're storing durations rather than points in time, you might want
to consider storing the duration in Long Integer seconds; these can be
formatted to minutes and seconds with an expression like

[Duration] \ 60 & Format([Duration] MOD 60, ":00")

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

24-hour clock format 4
Dlookup 7
Access Running Balance in Access 1
Time Calculation 10
Calculating Time Difference 2
How do I get total amount of hours in time format 3
elapsed time calculation help needed 1
Time formatting 1

Back
Top