Something wrong with my Module code

A

Adam

All,

I have a module that converts the time which comes out of another ODBC
database application.
Please can you see the below code, is there something wrong that you can
immediately see?
-----------
Function ConvertTime(InputValue As Variant) As Variant
Dim lngHour As Long
Dim lngMinute As Long
Dim lngSecond As Long

If IsNull(InputValue) = False Then
lngSecond = InputValue \ 256
lngMinute = (InputValue Mod 256) \ 65536
lngSecond = InputValue - (lngSecond * 256) - (lngMinute * 65536)
ConvertTime = TimeSerial(lngHour, lngMinute, lngSecond)
Else
ConvertTime = Null
End If

End Function
 
A

Andi Mayer

On Fri, 17 Dec 2004 03:09:01 -0800, "Adam"

show us a few values

If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
A

Adam

Hi Andy,

All the times are actually coming out as 12:00:00 AM which makes me believe
the module I made is causing an error.

The time 09:20:20 AM (hh:mm:ss) shows in the database as 152310784. If you
see the module below it shows how its calculated, it just isn't working :|
 
A

Adam

Hi Van,

I've corrected that part but when I run it I get the debug error on:

ConvertTime = TimeSerial(lngHour, lngMinute, lngSecond)

Any ideas?

Adam
 
A

Andi Mayer

Hi Andy,

All the times are actually coming out as 12:00:00 AM which makes me believe
the module I made is causing an error.

The time 09:20:20 AM (hh:mm:ss) shows in the database as 152310784. If you
see the module below it shows how its calculated, it just isn't working :|
What timeformat is that?????? a Day has 86400 seconds

From which System to you get this Number (OS and Program)


If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
V

Van T. Dinh

Have you checked to make sure your algorithm works out that:

0 <= lngHour < 24

and for simplicity (not actually required by TimeSerial):

0 <= lngMinute < 60
0 <= lngSecond < 60
?

I am not sure of the interpretation of the data from your ODBC source so
check and make sure you interpret it correctly and then code accordingly.

--
HTH
Van T. Dinh
MVP (Access)
 

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

Top