Jyina
Jyina

Reputation: 2892

How to add a form that is existing to a vb6 project?

I have a form "Search.frm" in my vb6 project. I want to add the same form with a different name "SearchNew.frm". I copied the form "Search.frm" and renamed to "SearchNew.frm" and tried to add to the project. But it is giving me an error "Search.frm will not be loaded. Name is already in use". Can anybody please help? Thank you.

Upvotes: 5

Views: 4940

Answers (3)

wqw
wqw

Reputation: 11991

How to clone a form in VB6:

  • Double-click your .frm file in explorer (so your form loads in separate project)
  • Change form's (name) in Properties window
  • Right-click on form -> Save Search.frm As...

If you are using custom controls thing get trickier:

  • Start VB6 and choose blank Standard EXE
  • Add Components (Ctrl+T) as necessary
  • Add .frm file to project (Ctrl+D)
  • Change form's (name)
  • Right-click form -> Save As...

Upvotes: 2

Dabblernl
Dabblernl

Reputation: 16101

To summarize the excellent answers and comments above:

  • Renaming the file is not enough, VB6 keeps the forms apart by their Name property.
  • Temporarily change the Name property of the existing Search.frm
  • Add the SearchNew.frm
  • Change the Name property of this form
  • Change the Name property of the original Search.frm back to what it was.

Upvotes: 4

user505255
user505255

Reputation: 320

It's been a long time since I wrote any VB6 code, but I'm pretty sure you need to change the Name property of the form, not just the filename, in order to use it as a separate form.

Upvotes: 1

Related Questions