Altering form and control properties via dll

Posted on 2006-06-13
Last Modified: 2010-04-30
Does anyone have any best practice, as it pertains to altering a form control property from a referenced dll?

For example, if I have a dll that gets called and is running a process... and I want a label in the calling form to say "please wait, processing" (caption property)...

But I do not want to change any code on the form... just do it from the dll class file.

Question by:born4code
  • 2
  • 2
LVL 13

Expert Comment

ID: 16898396

you can try somthing like this:

in your dll:

Public Sub update(lbl As Label, yourstuff As Variant)
   lbl.Caption = "Loading, please wait!"
End Sub

in your app:

Private Sub Command1_Click()
   update Label1, "your data and other things here"
End Sub

Author Comment

ID: 16898530
Yes, but if I am handling events then I don't have the luxury of passing the control variable.  That would be the obvious choice.  I am using a control handler... let say in the class I have...

Public Sub cmdUpdate_Click()  '<<<< handles the click event, no params passed
'something here
End Sub

LVL 13

Accepted Solution

Mark_FreeSoftware earned 500 total points
ID: 16898555

actually you can, but then use a public variable:

Dim outputlabel As Label

Private Sub Command1_Click()
   Set outputlabel = Label1
End Sub

Private Sub Command2_Click()
   outputlabel.Caption = "test"
End Sub

first press button one, (can be done in form load for example)

then press button 2,

the caption of label 1 is changing now.....

Author Comment

ID: 16899314
Ah... okay, what I did was put the declaration right inside of my Class file, and then set it in the form load of the page.  Then I can access it directory from the class.  Duh!

Works good this way.  The only thing that stinks is that it sure would be nice to pull it somewhere from an object elsewhere... I did experiment with VB.Forms object... and if I use the form name I can trace it down that way as well.


Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 102
MS Access Search and Replace Using VBA 6 70
Adding to a VBA? 6 69
Using an encrypted  value to decrypt and display contents in vb6 9 51
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.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

776 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