Writing DLLs in Delphi
What Happens if it does not Work...
The golden rule when working with DLLs, especially developing, is save your work every time you run the application. If the DLL crashes it will not be removed from memory automatically and a new version cannot be created until it is removed. To solve this problem, one of the most overlooked, but useful utilities, comes with VB3. It is WKS.EXE and you must tick the CDK options at the VB3 install. WKS.EXE is then placed in the VB\CDK directory. Using this tool find Rgdll.dll on the list and remove it using menu item Options/Free Module.
Determine whether the problem is with the Delphi or VB code. This is the reason I use Delphi and create the prototype before testing the DLL.
Make sure the byval and byref correspond with the Delphi var.
Check the VB variables type (Integer, single etc.) correspond with Delphi.
Not all VB variable types have a Delphi equivalent. Check the document that comes with Delphi called VB2delph.wri in the delphi\doc directory.
Use the Delphi wordbool type, not boolean, as wordbool returns 2 bytes to VB which is equivalent to VB's integer. This translates as 0 = false, 1= true not the VB values which are 0 = false, -1= true.