Consulting

Results 1 to 6 of 6

Thread: Modified a function that is called in another function, now getting runtime error?

  1. #1
    VBAX Regular
    Joined
    Jun 2017
    Posts
    23
    Location

    Modified a function that is called in another function, now getting runtime error?

    I found a small issue in a function that I corrected, but now when I run the main program I'm getting a run-time error 49: Bad DLL calling convention. When I hit debug it is selecting the line where the function I changed in being called into another function. I can run the function I changed without any issues or errors.

    It is being called by:

    call Verify
    The interesting part is the verify function runs, but after it shows the verify results the error pops up.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I don't think you are supposed to "Call" a Function procedure. You can "Call" a Sub procedure, even though it is not needed.

    Sub T()
    X = MyFunction
    MsgBox X
    
    MyProcedure
    End Sub
    
    Function MyFunction()
    MyFunction = "This is a Function Result"
    End Function
    
    Sub MyProcedure()
    MsgBox "This is from inside a Sub"
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Jun 2017
    Posts
    23
    Location
    I'm sorry it is a sub procedure. I don't use vba a lot, and just in the habit of calling everything functions. I tried removing the call, and the error is still there. You are right though as it still did the verify before the error.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Attach a small workbook with just enough code and data to show the problem
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Regular
    Joined
    Jun 2017
    Posts
    23
    Location
    Edit: Just figured it out. The issue was in the verify with something I changed, but wasn't showing the error there.
    Last edited by Zuccj; 08-11-2017 at 08:43 AM.

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    OK, going out on a limb and taking a BIG guess ...

    Without data and the DLL this is just shooting in the dark

    1. I guess MHL200 is the DLL

    2. The calls in Verify all seem to pass the handle and return a Long, except for ...

        Dim rvalue As Long
         
        ulMHL200Error = MHL200_LoadParams(ulMHL200Handle, holder)

    which seems like it returns string

    Sub write
        Dim value As Long
        Dim shown_value As Double
         
        If (holder = "Empty") Then

    I'm wondering if it a pointer to a string??? It's very hard to do more than that

    Sorry
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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