Solved

Invalid Use of New Keyword

Posted on 1998-06-05
15
289 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Concatenate 2 userform comboboxes to a userform text box 4 64
vb6 connector to mongodb 2 84
using web browser with BING 40 122
How to make an ADE file by code? 11 87
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 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