access frmMain code

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

How do I access a property of a control that is part of frmMain from a
class?
Example:

Public Class myClass

Public ReadOnly Property DWidth() As Integer

Get

DWidth = frmMain.myObject.Width

End Get

End Property
 
Hi Lou,

For this, first you'll need to create an instance of frmMain class in your
myClass. Here is an example:

Dim myfrm As New frmMain

Public ReadOnly Property DWidth() As Integer

Get

DWidth = frmMain.myObject.Width

End Get

End Property

This should work.

Thanks

Mona [GrapeCity]
 
Mona said:
For this, first you'll need to create an instance of frmMain class in your
myClass.

I don't think that this will solve the problem. Instead, it's better to
pass a reference to the existing instance of the main form to the class (in
a property or method parameter, for example).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top