If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Run-time Error 52 Bad filename or number

Actually, the close FNum statement is not the culprit. I added a message box after that line to see what FName is, and it comes up ?????????. However, just before calling the dll I have teh same message box and FName is correct. Any thoughts?

Re: Run-time Error 52 Bad filename or number

Well i wrote a small program and it seems Close statement in the above posted code will not give this error. There seems to be some other problem.

Not sure if you can step through the DLL. As your function (in the DLL) is not a big one, you can put simple Message Boxes after each statement and then you will be able to know which statement is actually erroring out.

Re: Run-time Error 52 Bad filename or number

slaphap,

I don't know what tool you used to create the DLL you have (I saw one tool before for compiling VB apps with functions into EAT like C++) but I think you should consider a way to avoid converting from UNICODE to ANSI and vise versa. It may confuse you and might give you more error as you go on with your project.

With the "Declare" keyword, VB converts strings from UNICODE to ANSI every time we enter the function and converts back the string (now from ANSI) to UNICODE. This would be confusing sometimes and might be hard to find where the error is. To avoid these translations, I could suggest you 2 options.

1. The first and easiest way is to make this DLL, an activeX dll. With this, you'll make sure that they are compatible as to transferring strings from the EXE to the DLL and back.

2. Second, you can make a type library (.TLB) for the DLL functions using the MIDL compiler. By doing this, you can tell VB that it should not translate the string and pass it as is into the function. Here's a sample for you dll function

Re: Run-time Error 52 Bad filename or number

Thanks for the help rxbagain. The problem is that this will be used with other source code other than VB and have been edicted to not use activeXdlls. I think I am getting a better grasp on things now. I do have a couple of questions more though..

1. Is there a way to step through a dll for debugging purposes?

2. Are Type declarations allowed in dlls? eg
public type xxx
x as integer
y as single
end type