Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

Invalid Use of New Keyword

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
clsmaster
Asked:
clsmaster
  • 9
  • 6
1 Solution
 
zsiCommented:
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
 
clsmasterAuthor Commented:
There is a reference to PropertyObject and I'm running SP3
0
 
clsmasterAuthor Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
zsiCommented:
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
 
clsmasterAuthor Commented:
How do I go about deregister my controls and DLLs
0
 
zsiCommented:
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
 
clsmasterAuthor Commented:
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
 
zsiCommented:
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
 
clsmasterAuthor Commented:
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
 
clsmasterAuthor Commented:
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
 
clsmasterAuthor Commented:
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
 
zsiCommented:
So is this resolved? :)
0
 
clsmasterAuthor Commented:
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
 
zsiCommented:
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
 
clsmasterAuthor Commented:
Thanks Please do post it if you can figure out what has happened here.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 9
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now