By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,146 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,146 IT Pros & Developers. It's quick & easy.

Open form inside form without closing previous form

P: 8
as title says.
I cant find a way to do this.
if i use form1.show and click on a button. it opens that form, but as soon as i click again it just reopens it and closes previously opened form.
So is there a way to avoid it?
im using 2 forms, main and secondary, i need to open secondary form as many times as needed (without making tons of new sub forms for that).

Idea is: i have main form with a button. i click on it and it opens new form where ican write note etc, i click again and it opens another one.

and to open those forms in a different place i use loop with time delay.

only problem is opening same form 2+ times.
Sep 27 '07 #1
Share this Question
Share on Google+
12 Replies


P: 8
oh and i forgot to add that it could also wrk like this:
i have 2 executables, one is main application and other is just a bare "notesheet", just like 2 forms, but:
1)how do i link 2nd .exe with first one, i can use shel lcommand but then i need to recompile every time folder name or path changes or is there a way to link exe if those are in the same folder no matter where that folder is, important is only that these 2 files are in the same directory.
2)id also like to use random location for each opened "notebook" window, but i dont know how to do it when i use shell command.
for form i used:
Form2.Left = RND() *pixels
Form2.Top = RND() *pixels
where pixels are some number for range/area of random location.
Sep 27 '07 #2

P: 8
sry for posting alone but forgot again that im using visual basic 6
Sep 27 '07 #3

P: 8
up noone knows how do do it?
Sep 28 '07 #4

jamesd0142
100+
P: 469
Me.Hide
form1.show

is this what you mean?

It hides the exisiting form but does not close it, and opens/shows the 2nd form.

Thanks
Sep 28 '07 #5

Ali Rizwan
100+
P: 927
as title says.
I cant find a way to do this.
if i use form1.show and click on a button. it opens that form, but as soon as i click again it just reopens it and closes previously opened form.
So is there a way to avoid it?
im using 2 forms, main and secondary, i need to open secondary form as many times as needed (without making tons of new sub forms for that).

Idea is: i have main form with a button. i click on it and it opens new form where ican write note etc, i click again and it opens another one.

and to open those forms in a different place i use loop with time delay.

only problem is opening same form 2+ times.
Hello
If you wnat to open the main form too as well as the secondary then use this code
Expand|Select|Wrap|Line Numbers
  1. me.enabled=false
  2. form2.show
  3.  
and when you want to close the secondary form on close button put this code
Expand|Select|Wrap|Line Numbers
  1.  
  2. me.hide
  3. form1.enabled=true
  4.  
And if you want to work on both forms then use this
Expand|Select|Wrap|Line Numbers
  1. form2.show
  2.  
GOODLUCK
Sep 28 '07 #6

P: 8
Well almost :)
actually i have two forms, form1 and form2
i would like to open form2 when i click on command button.
thats easy.
BUT if i click again command button, i want it to open form2 again, without closing previously opened form2 window aka id like to open form2 "n" times.
or is there a way to create another window when i click command button?

Actually id like to make simple notebook. when i click button on main form, it opens a window where i can write, if i click again, it opens another one without closing previous window.

and yeah id like to bay back to a friend who made joke on me so i would modify second copy of that program do do something else.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Do
  3. x = Rnd() * 11000
  4. y = Rnd() * 11000
  5. Form2.Left = x * Rnd()
  6. Form2.Top = y * Rnd()
  7. Form2.Show
  8. secStop = Timer + 0.1
  9. Do
  10. DoEvents
  11.     Loop Until Timer > secStop
  12. Loop
  13. End Sub
for that code i need same thing. i need to open new windows without closing previous. but it just reopens form2 and moves it around the screen.
Sep 30 '07 #7

jrtox
P: 89
Hello,
I do made a program that multiply N times but its an Object,(Label,textbox,buttons), not a Form. i tried and its quite Difficult...

what is your purpose of Showing your FORM2, N TIMES?
maybe we can do an alternative.

regards..
ervin
Oct 1 '07 #8

Ali Rizwan
100+
P: 927
Well almost :)
actually i have two forms, form1 and form2
i would like to open form2 when i click on command button.
thats easy.
BUT if i click again command button, i want it to open form2 again, without closing previously opened form2 window aka id like to open form2 "n" times.
or is there a way to create another window when i click command button?

Actually id like to make simple notebook. when i click button on main form, it opens a window where i can write, if i click again, it opens another one without closing previous window.

and yeah id like to bay back to a friend who made joke on me so i would modify second copy of that program do do something else.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Do
  3. x = Rnd() * 11000
  4. y = Rnd() * 11000
  5. Form2.Left = x * Rnd()
  6. Form2.Top = y * Rnd()
  7. Form2.Show
  8. secStop = Timer + 0.1
  9. Do
  10. DoEvents
  11.     Loop Until Timer > secStop
  12. Loop
  13. End Sub
for that code i need same thing. i need to open new windows without closing previous. but it just reopens form2 and moves it around the screen.
Yeah
There is a code by which we can open a form n times.
This code will make infinite number of forms. Form2 must exist.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim frm As Form2
  3.  
  4.   Set frm = New Form2  Call Load(frm)
  5.   Call frm.Show(vbModeless)
  6.  
  7.  
GOOD LUCK
ALI
Oct 1 '07 #9

P: 8
Set frm = New Form2 Call Load(frm)
it shows error on this line. And hilights Cell lstatement (syntax error, expected end of statement)
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Do
  3. x = Rnd() * 11000
  4. y = Rnd() * 11000
  5. Form2.Left = x * Rnd()
  6. Form2.Top = y * Rnd()
  7. Dim frm As Form2
  8.   Set frm = New Form2 Call Load(frm)
  9.   Call frm.Show(vbModeless)
  10. secStop = Timer + 0.1
  11. Do
  12. DoEvents
  13.     Loop Until Timer > secStop
  14. Loop
  15. End Sub
Oct 1 '07 #10

QVeen72
Expert 100+
P: 1,445
Hi,

THIS IS ENOUGH FOR VB6

Expand|Select|Wrap|Line Numbers
  1.     Dim tfrm As New Form2
  2.     tfrm.Show
  3.  
REgards
Veena
Oct 1 '07 #11

P: 8
with this code it does open new form good for notebook app.

but now that other code where id like it to open it automatically, every time different location (command button triggers it).
code worked with form2.show (it just moved form2), but when i use
Dim tfrm As New Form2
tfrm.Show
it opens new each time i CLICK on button but it doesent do it automatically and it wont open in different locatio neach time.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Do
  3. x = Rnd() * 11000
  4. y = Rnd() * 11000
  5. Form2.Left = x * Rnd()
  6. Form2.Top = y * Rnd()
  7. Dim tfrm As New Form2
  8.     tfrm.Show
  9. secStop = Timer + 0.1
  10. Do
  11. DoEvents
  12.     Loop Until Timer > secStop
  13. Loop
  14. End Sub
Oct 1 '07 #12

P: 8
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. x = Rnd() * 11000
  3. y = Rnd() * 11000
  4. Form2.Left = x * Rnd()
  5. Form2.Top = y * Rnd()
  6. secStop = Timer + 0.1
  7. Do
  8. Form2.Show
  9.     Loop Until Timer > secStop
  10. End Sub
  11.  
cant edit last post :/
so made a little cleanup in the code.
tho i can find a way to implement
Expand|Select|Wrap|Line Numbers
  1. Dim tfrm As New Form2
  2.     tfrm.Show
if i replace Form2.Show than it wont change location each time.
i cand edit form2.left/top with tfrm.left/top i get duplicate declaration error.
Oct 1 '07 #13

Post your reply

Sign in to post your reply or Sign up for a free account.