Argument not optional (Error 449)
Problem :
Argument not optional (Error 449) pops up in VB
Applies to: VB6 applications using VC6 Activex controls.
Solution:
The usual reasons for this error is documented in
http://msdn2.microsoft.com/en-us/library/102s19ky.aspx
Another reason this could occur suddenly is when you change the function definition in the ocx.
For eg. you had a function called BOOL MyFunc(String) and you decided to change it to BOOL MyFunc()
But in your VB code when you remove the argument you get the above error and if you don't remove you get an argument mismatch error.
Solution: Make sure that you have changed the follwing three.
1) The header file afx_msg BOOL MyFunc();
2) The cpp file BOOL CMyCtrl::MyFunc()
3) The odl file [id(2)] boolean MyFunc();
and
4) The DISPATCH MAP
DISP_FUNCTION(CMyCtrl, "MyFunc", MyFunc, VT_BOOL, VTS_NONE)
Even if you don't change 4 the intellisense of VB shows the correct form of the function and there won't be any compilation error but it will fail while running.
Argument not optional (Error 449) pops up in VB
Applies to: VB6 applications using VC6 Activex controls.
Solution:
The usual reasons for this error is documented in
http://msdn2.microsoft.com/en-us/library/102s19ky.aspx
Another reason this could occur suddenly is when you change the function definition in the ocx.
For eg. you had a function called BOOL MyFunc(String) and you decided to change it to BOOL MyFunc()
But in your VB code when you remove the argument you get the above error and if you don't remove you get an argument mismatch error.
Solution: Make sure that you have changed the follwing three.
1) The header file afx_msg BOOL MyFunc();
2) The cpp file BOOL CMyCtrl::MyFunc()
3) The odl file [id(2)] boolean MyFunc();
and
4) The DISPATCH MAP
DISP_FUNCTION(CMyCtrl, "MyFunc", MyFunc, VT_BOOL, VTS_NONE)
Even if you don't change 4 the intellisense of VB shows the correct form of the function and there won't be any compilation error but it will fail while running.
© Copyright 2006. Bipin C Nair. All rights reserved.