Solved

Invalid Use of New Keyword

Posted on 1998-06-05
15
294 Views
Last Modified: 2010-05-03
I have a Visual Basic 5.0 Group with several projects in it.  Some ActiveX controls and 1 ActiveX Server.  Everything was working fine with no problems.  Then I decided to do a Build Project Group command.  This worked fine until it got to the main EXE program and gave me the error message or Invalid Use of New Keyword on the following line:
Private House as new PropertyObject

Now this line has worked fine before when I just ran the program in VB.  Now after I did the Make Project Group Command and it rebuilt the PropertyObject Class I can not even run the program in VB5.0 anymore.

Anyone please help I have no clue as to the cause of this problem or how to go about fixing it, but this is holding me back from continueing.
0
Comment
Question by:clsmaster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
15 Comments
 
LVL 4

Expert Comment

by:zsi
ID: 1462614
Check to make sure that the object containing PropertyObject has a valid reference, one that is up to date.  It is looking through the list of valid object references and not finding PropertyObject.

Also, as a safeguard, make sure that you are running SP3.

zsi
0
 

Author Comment

by:clsmaster
ID: 1462615
There is a reference to PropertyObject and I'm running SP3
0
 

Author Comment

by:clsmaster
ID: 1462616
Here is the odd thing about that though.  If I retype that line Properties appears on the list after the new keyword.  And House is used throughout the project.
If I go into references I can uncheck the PropertyObject reference without any problems (it does not say object is use)
If I then go back into the code and try to retype the line Properties does not appear in the list.  Why doesn't it say that the PropertyObject Reference is in use????
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 4

Expert Comment

by:zsi
ID: 1462617
You only get that message if the reference is to an OCX control that is being used on a form.  The system does not verify the use of an object in code when you remove a reference.

This is a very desirable feature.  When you recompile a DLL or EXE that is being referenced, you have to de-reference it, close the references dialog box, and then re-reference the object.  If the system would not allow you to de-reference an object that was referred to in code, you would have to comment out all of the code, refresh the reference, and then uncomment the code again.  That would be a nightmare.

Try this: instead of using early binding (Dim x as New r.o), try using late binding (dim x as object.  Set x = CreateObject("r.o") ) and see if that allows you to get around the problem.

If it does, then you know that you were trying to refer to an invalid object.

Also, just to make sure that everything was registered correctly, you should unregister your project's DLL/EXEs and re-register them.  

Lastly, once this is all resolved, you should look in the manual for information on binary compatibility.  This will help to alleviate problems in the future.

zsi
0
 

Author Comment

by:clsmaster
ID: 1462618
How do I go about deregister my controls and DLLs
0
 
LVL 4

Expert Comment

by:zsi
ID: 1462619
For the dll, use RegSvr32 with the /u parameter.

Just make sure that you do not unregister any system dlls - only the ones that you have created with your project.
0
 

Author Comment

by:clsmaster
ID: 1462620
Doing late binding works.
I then went into VB References and the PropertyObject Reference.
I then ran regsvr32 /u on the DLL
I then ran regsrv32 on the DLL (to register it)
I then switched back to VB and reselect the PropertyObject Ref.
I then tried to run the program, but still got the error with the new keyword.


How do I fix this???? I really don't want to have to do late binding because it makes it a lot easier to program with early bind statement completion and all.

PLEASE HELP
0
 
LVL 4

Expert Comment

by:zsi
ID: 1462621
Are you sure that the file that you are unregistering and re-registering is the same one that you are using in your app?  Search through your computer and make sure that you do not have duplicate versions of the dll.  If you do, make it so that you are only using the one that your are registering.  

0
 

Author Comment

by:clsmaster
ID: 1462622
Yeah I did A find and no other matches came up, also in the reference dialog box the path is the same.  This time after I did /u I did make PropertyObject.dll instead of doing regsrv32 again.

Here's an odd thing if I make a new EXE and go into the references box the name of the same DLL is not the same as in the program.  In the new EXE I only have the EXE not the DLL.  Also it works perfectly fine here.
0
 

Author Comment

by:clsmaster
ID: 1462623
If I add the project to the new EXE then the name changes back to what it is in the real program, but everything still works fine.
0
 

Author Comment

by:clsmaster
ID: 1462624
I found a way to fix it.  In the new EXE I just Add all the projects and forms from the original and now it works.
0
 
LVL 4

Expert Comment

by:zsi
ID: 1462625
So is this resolved? :)
0
 

Author Comment

by:clsmaster
ID: 1462626
If you don't know the answer of what, so that if and when I run into a similar problem I'll know the anwser.
Also either way fell free to submit something as an answer, so I can give you the points, you've been a big help either way.
0
 
LVL 4

Accepted Solution

by:
zsi earned 90 total points
ID: 1462627
If I can find a more difinitive answer, I will post it here.  It is definetly a registration problem, however.

I have experienced this problem before, I am sure it will come back to me.

zsi
0
 

Author Comment

by:clsmaster
ID: 1462628
Thanks Please do post it if you can figure out what has happened here.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question