PDA

View Full Version : Calling gmtime function from CRTDLL failed



Marlog
03-24-2006, 02:32 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.

Killian
03-28-2006, 03:21 AM
Hi Marlog,

There can be a few reasons for this error but I think the reason for yours is explained here (http://support.microsoft.com/default.aspx?scid=kb;en-us;Q153586)

matthewspatrick
03-29-2006, 05:32 AM
Another possible problem: your user-defined Type uses the VBA Integer data type, but the DLL function you are calling uses the C++ Int data type. C++ Int = VBA Long, not VBA Integer.