|
-
Jun 28th, 2012, 08:12 PM
#1
Thread Starter
Fanatic Member
adding in military time
im tring to get the answer +2 by takeing elasped witch is -22 from offset ?
but its adding it
thanks and happy 4th
Code:
Private Sub Command3_Click()
Dim start1 As String
Dim stop1 As String
Dim elasped As String
Dim offset As String
offset = "24."
start1 = "23."
stop1 = "01.00"
elasped = stop1 - start1
If elasped < 1 Then
elasped = offset - elasped
MsgBox elasped
Else
MsgBox elasped
End If
End Sub
Last edited by flyhigh; Jun 29th, 2012 at 07:13 AM.
-
Jun 28th, 2012, 08:27 PM
#2
Thread Starter
Fanatic Member
Re: [RESOLVED] adding in military time
i forgot about this ..im sorry
Abs(elasped)
-
Jun 28th, 2012, 08:59 PM
#3
Re: [RESOLVED] adding in military time
You should not be using strings for math, very bad practice.
-
Jun 29th, 2012, 07:09 AM
#4
Thread Starter
Fanatic Member
Re: [RESOLVED] adding in military time
is this right with military time
Code:
Private Sub Command3_Click()
Dim start1 As Double
Dim stop1 As Double
Dim elasped As Double
Dim offset As Double
offset = Val("24.")
start1 = Val("23.")
stop1 = Val("1.")
elasped = stop1 - start1
MsgBox elasped
If elasped < 0 Then
elasped = offset - Abs(elasped)
MsgBox elasped
Else
MsgBox elasped
End If
End Sub
-
Jun 29th, 2012, 07:27 AM
#5
Re: adding in military time
Why use strings at all? why not:-
code Code:
Dim start1 As Double
Dim stop1 As Double
Dim elasped As Double
Dim offset As Double
offset = 24
start1 = 23
stop1 = 1
And you don't need that ABS because you're only subtracting it from offset if it's negative. Why not just do this:-
code Code:
elasped = offset + elasped
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Jun 29th, 2012, 07:39 AM
#6
Thread Starter
Fanatic Member
Re: adding in military time
that works but the time should be 2300 or 0100
-
Jun 29th, 2012, 08:13 AM
#7
Re: adding in military time
You should be using two date objects, and then using DateDiff to get the difference in hours.... the fact that it's "Military time" is irrelevant as that's just display...
-tg
-
Jun 29th, 2012, 01:01 PM
#8
Thread Starter
Fanatic Member
Re: adding in military time
im tring to get the difference in hours , but the time may start at anytime 11:00 pm wait form 24 or more hours and restart.
-
Jun 29th, 2012, 01:16 PM
#9
Re: adding in military time
all the more reason to use a date variable.... the difference between 6/27/2012 11:00pm and 6/28/2012 1:00am is 2 hours... but the 6/27/2012 11:00pm and 6/29/2012 1:00am is 26 hours...
-tg
-
Jun 29th, 2012, 01:39 PM
#10
Re: adding in military time
No doubt you should be using a date variable and the datediff() function. If you need it displayed a certian way then you just use a format() function to get the desired result.
-
Jul 1st, 2012, 11:11 AM
#11
Thread Starter
Fanatic Member
Re: adding in military time
hey yall why does this show an hour even when its only been 40 minutes?
does it round off the numbers?
Code:
If timelimit = "" Then timelimit = Format(Now())
timenow = Format(Now())
Label1.Caption = timelimit
Label2.Caption = Format(Now())
Label3.Caption = DateDiff("h", timelimit, timenow)
datdiff = DateDiff("h", timelimit, timenow)
-
Jul 3rd, 2012, 11:42 AM
#12
Thread Starter
Fanatic Member
Re: adding in military time
hey yall timelimit is 12 and 1/2 hours ago why does this code round off to nearest number?
Code:
timenow = Format(Now())
datdiff = DateDiff("h", timelimit, timenow)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|