Consulting

Results 1 to 3 of 3

Thread: Calling gmtime function from CRTDLL failed

  1. #1
    VBAX Newbie
    Joined
    Mar 2006
    Posts
    2
    Location

    Unhappy Calling gmtime function from CRTDLL failed

    The next code

    [vba]
    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
    [/vba]

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

    Does anybody know the reason?

    With regards,
    Marlog.

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi Marlog,

    There can be a few reasons for this error but I think the reason for yours is explained here
    K :-)

  3. #3
    VBAX Expert
    Joined
    Jul 2004
    Location
    Wilmington, DE
    Posts
    600
    Location
    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.
    Regards,

    Patrick

    I wept for myself because I had no PivotTable.

    Then I met a man who had no AutoFilter.

    Microsoft MVP for Excel, 2007 & 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •