PDA

View Full Version : Calling function gmtime from system dll fails.



Marlog
03-24-2006, 09:56 AM
The next code


Option Explicit


Type tm
tm_sec As Integer
tm_min As Integer
tm_hour As Integer
tm_mday As Integer
tm_mon As Integer
tm_year As Integer
tm_wday As Integer
tm_yday As Integer
tm_isdst As Integer
End Type

Private Declare Function gmtime Lib "crtdll" (ByVal val&) As tm

Public Sub R()
Dim T As tm
Dim v As Long
v = 0
T = gmtime(v)
MsgBox T.tm_year
End Sub


generates Error 49= "Bad DLL calling convention" on line with gmtime call

Does anybody know the reason?

With regards,
Marlog.

XLGibbs
03-25-2006, 06:41 AM
You have defined the type, but your function also needs to specify which piece of th UDT is being set..in this case you want to set the tm_year

probably something like : tm_year = gmTime(v)

Not sure on the bad call error, but I think you have to place the tm_year value to the UDT variable.

matthewspatrick
03-25-2006, 11:51 AM
I think you need to redefine the data types in your user-defined type tm. The gmTime function you are referencing is using the C++ int data type, which corresponds to VBA Long and not VBA Integer.