Solved

Add a sub form to a main form in visual basic

Posted on 2004-03-21
6
908 Views
Last Modified: 2006-11-17
Hi,

Can some one explain to me how to add a subform to a main form in visual basic, then in turn link the forms together?

thanks
0
Comment
Question by:kinton
6 Comments
 
LVL 22

Expert Comment

by:cookre
Comment Utility
Add a new form with Project/Add Form, say Form2.

In Form1, when you want to bring up Form2, do:
Form2.Show

If you don't want Form1 to appear while Form2 is up:
Form1.Hide
Form2.Show

When you're done with Form2, do
Form1.Show

And if you want the cursor to be in a particular field:
Form1.Fieldx.SetFocus
0
 

Expert Comment

by:Fox_What
Comment Utility
Also, if you want form2 to show and not be able
to click on form1 while it is active you can do:

form2.show vbModal, form1.hwnd
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
You asked about subforms in VB.  VB doesn't support a true subform.  You can simulate it as shown above.

mlmcc
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Expert Comment

by:sreekanth_k77
Comment Utility
It is so simple to do that.

Create a new form using File --> New Form --> give some name to that form( form2.frm)
then write the following code in button click event.

Private Sub Command1_click()
  form2.show
  form1.hide  ' Write this code if you want to hide the first window.
End Sub
0
 
LVL 2

Accepted Solution

by:
Ivan_Skrinjaric earned 500 total points
Comment Utility
0
 
LVL 2

Author Comment

by:kinton
Comment Utility
Sorry about the bad explanation of the question, but against all odds Ivan, you knew exactly what I needed.  Thanks for your help.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now