Consulting

Results 1 to 3 of 3

Thread: Calling function gmtime from system dll fails.

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

    Unhappy Calling function gmtime from system dll fails.

    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 XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    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.
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




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