Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error when trying to use a class in a .ocx 1

Status
Not open for further replies.

ExtraD

Programmer
Jul 6, 2005
41
NL
Hi,

I’m trying to use a class that’s created in an ocx. For the post I created a small sample project which is as following:

A ocx project called: Project1

class module called: Class1
Option Explicit

Private mStategroup As String

Public Property Get Stategroup() As String
Stategroup = mStategroup
End Property

Public Property Let Stategroup(ByVal lNewValue As String)
mStategroup = lNewValue
End Property

I created a visual basic project called: Project1
I inserted the ocx in the components tab of the vb project and placed this on the form.
On the form I placed 1 button and used this code:

Private Sub Command1_Click()
Dim test As Project1.Class1
Set test = New Class1
test.Stategroup = "test"
End Sub


When I now run the project I get the following message “invalid use of New keyword”

If you could help me???

Thanx!!!!!!

 
For starters. Your (vb)Client and (ocx)Server Projects are both called Project1. I should try calling one of them something different.
 
ok this changed. stil the same problem :(
 
ok I'm not big on ocx's and am only trying to help so bear with me.

I'm thinking the ocx is a Control on your Form typically called MyOcx1. Therefore maybe you should be calling its Properties and Methods with reference to the Control on the Form rather than creating another Object for it using New like;

result = me.MyOcx1.MyProp

me.MyOcx1.MyProp = myvalue


HTH

 
Alternatively (with your original code) try deleting the ref to the ocx in Components and add it under Project References.
 
Class1 would need to have its Instancing property set to MultiUse(5) or GlobalMultiUse(6) to instantiate it outside of the OCX project. My guess is right now it's set to Private(1).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top