PDA

View Full Version : [SOLVED] Modified a function that is called in another function, now getting runtime error?



Zuccj
08-11-2017, 05:40 AM
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.

SamT
08-11-2017, 06:15 AM
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

Zuccj
08-11-2017, 06:21 AM
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.

Paul_Hossler
08-11-2017, 08:01 AM
Attach a small workbook with just enough code and data to show the problem

Zuccj
08-11-2017, 08:28 AM
Edit: Just figured it out. The issue was in the verify with something I changed, but wasn't showing the error there.

Paul_Hossler
08-11-2017, 08:43 AM
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