Archived Forum Post

Index of archived forum posts


Invalid use of New Keyword

Sep 05 '12 at 10:47

I am testing your toolkit. I got an error when I declared an object of IMAP in Visual Basic 6. Do you know how to overcome this error?

dim imap as new ChilkatImap

Compile error
Invalid use of New keyword


This error occurs if you incorrectly add the ActiveX component to your VB6 project. Follow these rules:

1) If the ActiveX objects are dynamically created (they are not dragged and dropped onto a form from the palette), then add a Reference to the ActiveX. You should NOT see the icons for the ActiveX in the palette. Instances of the ActiveX objects are created by New statements in your code.

2) If the Chilkat ActiveX objects are dragged and dropped onto your form, then add the component via the “Project–>Components” menu, NOT the “Project–>References” menu. In my opinion, it is always better to create instances of the objects dynamically because the Chilkat objects are not visual controls and won’t be visible on your form anyway at runtime.

3) Never do both — you should either add a Reference (Project–>References) or add the component to the palette (Project–>Components) but NEVER BOTH.