Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Visual class from a form?

Visual class from a form?

Visual class from a form?

I have a form with methods and propperties that I want to use in the rest of the forms of my application. Can I create a *visual class* from this form?

I'm new in VB6. With VFP (and other OOP languages) this task can be done quickly and efficiently.

Using Dim frmOne As New frmClass doesn't work 'cos I need instantiate the form object at *design time*.


RE: Visual class from a form?

maybe I did'nt understand....for a procedure, function or any other to be visible by other forms in the app. they must be declared as public...

public sub yourproc()
'your code
end sub


public function(your var)

end function

RE: Visual class from a form?


What I want is to INSTANTIATE a form in design time.
I want a form INHERIT methods and properties from a form class in order to do all forms work the same way.
Other way is cut and paste code into new forms. This is what I'm doing right now. Obviously this is not efficient.

(To VFPers: I can do this task by selecting the form and doing "Save as class..." and instantiating new forms from this class)

(excuse my bad english)

RE: Visual class from a form?

you can do this by creating multiple instances of the same form...yes...I have done this with mdi creating multiple instances of the child form.

Am I on the right track here?

A great book for learning this is called

Visual Basic Programmer's Library published by Jamsa Press

RE: Visual class from a form?

Maybe I need a book for learning english ;-)

Positran, you do that at run-time (I think). I want to do it at design-time, so I can modify some controls of each form class' instances. Yes, I mean polimorphysm.

The model form have some methods and properties that must be common for all forms, but each form instance have different controls within them.

I wonder it's so easy to do it in VFP and other OOP languages. I'm getting the conclussion that this can't be done in VB and I will have to cut and paste code in new forms and re-write *each form code* everytime I define a change in the forms behaviour's logics.

RE: Visual class from a form?

you could start a new form. Design it the way you want to adding the controls and setting the properties. Use the save as to save it as say...."frmTemplate." Then you can add frmTemplate to the project as often as you want...but you can only have one instance of the form with that name. So you will need to save the original frmTemplate as something else...say "frmMain". Now you can add a new frmTemplate to the project. Any time you want to add another just rename frmTemplate to something else and add a new one. Remember you must use "Save as..." because simply renaming the form will not get the job done.

RE: Visual class from a form?

I think that what you want can be done creating an ActiveX control with the form and create the properties and methods at design time.

RE: Visual class from a form?

What happens when I change the logics of the original form?...
I should change the source code of the "instances" mannually. That's what I'm doing already.

Can I redefine the methods and properties AND CONTROLS of each instance of the Activex control?

RE: Visual class from a form?

Making an AxControl you can create your own properties, you should create control arrays and change their properties.
Is like subclassing.
On your property page of the Axcontrol you define all the diferents properties you want to make available and change them at design time.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close