Open form inside form without closing previous form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • djmauro
    New Member
    • Sep 2007
    • 8

    Open form inside form without closing previous form

    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.
  • djmauro
    New Member
    • Sep 2007
    • 8

    #2
    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.

    Comment

    • djmauro
      New Member
      • Sep 2007
      • 8

      #3
      sry for posting alone but forgot again that im using visual basic 6

      Comment

      • djmauro
        New Member
        • Sep 2007
        • 8

        #4
        up noone knows how do do it?

        Comment

        • jamesd0142
          Contributor
          • Sep 2007
          • 471

          #5
          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

          Comment

          • Ali Rizwan
            Banned
            Contributor
            • Aug 2007
            • 931

            #6
            Originally posted by djmauro
            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
            Code:
            me.enabled=false
            form2.show
            and when you want to close the secondary form on close button put this code
            Code:
             
            me.hide
            form1.enabled=true
            And if you want to work on both forms then use this
            Code:
            form2.show
            GOODLUCK

            Comment

            • djmauro
              New Member
              • Sep 2007
              • 8

              #7
              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.
              Code:
              Private Sub Command1_Click()
              Do
              x = Rnd() * 11000
              y = Rnd() * 11000
              Form2.Left = x * Rnd()
              Form2.Top = y * Rnd()
              Form2.Show
              secStop = Timer + 0.1
              Do
              DoEvents
                  Loop Until Timer > secStop
              Loop
              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.

              Comment

              • jrtox
                New Member
                • Sep 2007
                • 89

                #8
                Hello,
                I do made a program that multiply N times but its an Object,(Label,t extbox,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

                Comment

                • Ali Rizwan
                  Banned
                  Contributor
                  • Aug 2007
                  • 931

                  #9
                  Originally posted by djmauro
                  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.
                  Code:
                  Private Sub Command1_Click()
                  Do
                  x = Rnd() * 11000
                  y = Rnd() * 11000
                  Form2.Left = x * Rnd()
                  Form2.Top = y * Rnd()
                  Form2.Show
                  secStop = Timer + 0.1
                  Do
                  DoEvents
                      Loop Until Timer > secStop
                  Loop
                  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.

                  Code:
                  Dim frm As Form2
                    
                    Set frm = New Form2  Call Load(frm)
                    Call frm.Show(vbModeless)
                  GOOD LUCK
                  ALI

                  Comment

                  • djmauro
                    New Member
                    • Sep 2007
                    • 8

                    #10
                    Set frm = New Form2 Call Load(frm)
                    it shows error on this line. And hilights Cell lstatement (syntax error, expected end of statement)
                    Code:
                    Private Sub Command1_Click()
                    Do
                    x = Rnd() * 11000
                    y = Rnd() * 11000
                    Form2.Left = x * Rnd()
                    Form2.Top = y * Rnd()
                    Dim frm As Form2
                      Set frm = New Form2 Call Load(frm)
                      Call frm.Show(vbModeless)
                    secStop = Timer + 0.1
                    Do
                    DoEvents
                        Loop Until Timer > secStop
                    Loop
                    End Sub

                    Comment

                    • QVeen72
                      Recognized Expert Top Contributor
                      • Oct 2006
                      • 1445

                      #11
                      Hi,

                      THIS IS ENOUGH FOR VB6

                      [CODE=VB]
                      Dim tfrm As New Form2
                      tfrm.Show
                      [/CODE]

                      REgards
                      Veena

                      Comment

                      • djmauro
                        New Member
                        • Sep 2007
                        • 8

                        #12
                        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.
                        Code:
                        Private Sub Command1_Click()
                        Do
                        x = Rnd() * 11000
                        y = Rnd() * 11000
                        Form2.Left = x * Rnd()
                        Form2.Top = y * Rnd()
                        Dim tfrm As New Form2
                            tfrm.Show
                        secStop = Timer + 0.1
                        Do
                        DoEvents
                            Loop Until Timer > secStop
                        Loop
                        End Sub

                        Comment

                        • djmauro
                          New Member
                          • Sep 2007
                          • 8

                          #13
                          Code:
                          Private Sub Command1_Click()
                          x = Rnd() * 11000
                          y = Rnd() * 11000
                          Form2.Left = x * Rnd()
                          Form2.Top = y * Rnd()
                          secStop = Timer + 0.1
                          Do
                          Form2.Show
                              Loop Until Timer > secStop
                          End Sub
                          cant edit last post :/
                          so made a little cleanup in the code.
                          tho i can find a way to implement
                          Code:
                          Dim tfrm As New Form2
                              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.

                          Comment

                          Working...