
Pass control array to sub/function ?
Harry: I've posted the help article below, but I'm wondering if it applies
to your situation. If you want to look for it, pull up "Difference in
Passing Controls Between Visual Basic 3.0 and Visual Basic 4.0 (ReadMe)" in
your online help. It suggests that you need to explicitly pass the
parameter (your control array) by value.
Hope this works.
Bret
Quote:
>>Begin Help Article:
If you are calling a Function or Sub procedure in a .DLL or .VBX that was
written for Visual Basic 3.0, and the Declare statement for the Function or
Sub has a parameter that is defined As Control, then the correct Visual
Basic 4.0 parameter should have a ByVal preceding the parameter name. This
is because in Visual Basic 3.0 a parameter defined As Control incorrectly
passed an hCtl (the handle to the control) rather than a pointer to the
hCtl. Because all other parameters passed by reference (they had no ByVal
preceding them) were passed as pointers to the parameters, the As Control
parameters were an exception which has been corrected in Visual Basic 4.0.
For example, a DLL function such as:
HWND FAR Pascal GetControlHwnd(HCTL hCtl)
{
return VBGetControlHwnd(hCtl);
Quote:
}
would have a Visual Basic 3.0 declaration of:
Declare Function GetControlHwnd Lib libname.dll (hCtl As Control) _
As Integer
and should have a Visual Basic 4.0 declaration of:
Declare Function GetControlHwnd Lib libname.dll (ByVal hCtl As _
Control) As Integer
Visual Basic 4.0 resolves this problem in the vast majority of the cases,
and can correctly identify the proper value to pass to Visual Basic APIs.
However, to make absolutely sure that the program using this .VBX or .DLL
will be compatible with future releases of Visual Basic, you should follow
the correct methodology in setting parameters.
End Help Article <<