Solved

Recognising variables in an ActiveX DLL

Posted on 1998-06-20
3
146 Views
Last Modified: 2010-05-03
Hello,
I am having a few problems with an ActiveX DLL that I have done (one of my first experiments) with VB5 Professional.

I have created a class (HaroldsClass) in the DLL, in which I instantiate a form, as follows:

Private haroldsform As Form1
Set haroldsform = New Form1

I have placed a commandbutton and a textbox on the form, and attached the following code:

Private Sub CommandOK_Click()
HaroldsClass.NewText = Text1.Text
Unload Me

End Sub

NewText is a public property (Get/Let) of HaroldsClass.

Now I would expect that the Haroldsclass property addressed in HaroldsForm above would be recognised by the form, as the form was itself created in Haroldsclass.  But no matter what I do, I cannot get any of my public Haroldsclass properties recognised within the bounds of the form Haroldsform.

HELP!!  What am I doing wrong??

Anwsers with code much appreciated, please.

TrimTrom
0
Comment
Question by:trimtrom
  • 2
3 Comments
 

Author Comment

by:trimtrom
ID: 1463859
Edited text of question
0
 
LVL 2

Accepted Solution

by:
Llandr earned 100 total points
ID: 1463860
It seems to me that what you are doing is confusing a Class and an Object. An object is an instance of a class. This means that you cannot reference methods in the Harrold-class without a specific object there to reference.

This is the way to make it work, note the use of then backreference (is there a better word?):
<-------- code starts --------->

<Module modStart>
Option Explicit

Public Sub Main()
  Dim cls As New CHarroldsClass
 
  cls.DoShow
End Sub

<Class CHarroldsClass>
Option Explicit

Private mText As String
Private mForm As frmHarrlodsForm

Public Property Let NewText(newT As String)
  mText = newT
End Property

Public Property Get NewText() As String
  NewText = mText
End Property

Public Sub DoShow()
  Set mForm = New frmHarrlodsForm
  Set mForm.BackReference = Me
  mForm.Show 1
  MsgBox "New text:" & NewText
End Sub

<Form frmHarrlodsForm>
Option Explicit

Public BackReference As CHarroldsClass


Private Sub cmdSetText_Click()
  BackReference.NewText = txtText
  Hide
End Sub
<------Code ends------------->
0
 

Author Comment

by:trimtrom
ID: 1463861
OK Thanks: really well expressed answer!
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 59
message box in access 4 46
vb6 connector to mongodb 2 84
Advice in Xamarin 21 79
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

772 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