Code after Form.Show

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Nunnally
    New Member
    • Jul 2007
    • 56

    Code after Form.Show

    Its been a while since I worked with VB6, so hang with me if this is stupid. How do I get past the Form.show method if I call it in a function? Here is the scenario.

    Sub Whatever()
    Some Code Here

    frmProcess.Show vbModal

    Some More Code Here

    end sub

    I want it to process the "Some More Code Here" portion after the form is shown. But it just shows the form and hangs until I close the form. Then it moves onto the "Some More Code Here" portion.

    I tried moving "Some More Code Here" to the form load of frmProcess. The thing with that is once "Some More Code Here" is done, then I don't need the form up anymore. So putting it on form load never shows the form.

    Its like I need another thread or something, but I don't think I can do that in VB6, right?

    How can I just display the form and move on?
  • Ali Rizwan
    Banned
    Contributor
    • Aug 2007
    • 931

    #2
    Originally posted by Matt Nunnally
    Its been a while since I worked with VB6, so hang with me if this is stupid. How do I get past the Form.show method if I call it in a function? Here is the scenario.

    Sub Whatever()
    Some Code Here

    frmProcess.Show vbModal

    Some More Code Here

    end sub

    I want it to process the "Some More Code Here" portion after the form is shown. But it just shows the form and hangs until I close the form. Then it moves onto the "Some More Code Here" portion.

    I tried moving "Some More Code Here" to the form load of frmProcess. The thing with that is once "Some More Code Here" is done, then I don't need the form up anymore. So putting it on form load never shows the form.

    Its like I need another thread or something, but I don't think I can do that in VB6, right?

    How can I just display the form and move on?

    I am using this statement now at this time on an database and is doing well i have not found any problem with this code.

    Now use this one

    Private Sub ()

    text1.text=5 (Some code)
    frm.Show
    frm.text1.text= 5 (Some more code)

    End Sub

    try it if it does not work then i will send u another solution.

    Comment

    • Matt Nunnally
      New Member
      • Jul 2007
      • 56

      #3
      Ali,

      Thanks for the reply. I tried that code. However, if I remove "vbModal" I get an error. Is that what you were suggesting?

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by Matt Nunnally
        ... if I remove "vbModal" I get an error ...
        Can you give us more detail on the error, such as where it occurs? And when?

        When you show a window modally, that means it takes control and doesn't return it until the window is unloaded or (I think) hidden. So there's no getting around the fact that you cannot continue on past the Show statement unless (A) the form is hidden/unloaded, or (B) it is shown non-modally.

        I think it is possible to do multiple threads, but don't have any experience with them. It's probably unnecessary in this case, though.

        Comment

        • Matt Nunnally
          New Member
          • Jul 2007
          • 56

          #5
          I get 5-Invalid procedure call or argument on the Form.Show.

          I also tried this as a work around. I called the frmProcess.Show when my project starts up. Then on the form load of frmProcess, I call me.hide. Then when it is time to show the form, I just call frmProcess.visi ble = true. I unload the form when I'm done with it. But with this I get a runtime error 402, must close or hide topmost modal form first, when I call the me.hide on the Form Load of frmProcess.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by Matt Nunnally
            I get 5-Invalid procedure call or argument on the Form.Show.

            I also tried this as a work around. I called the frmProcess.Show when my project starts up. Then on the form load of frmProcess, I call me.hide. Then when it is time to show the form, I just call frmProcess.visi ble = true. I unload the form when I'm done with it. But with this I get a runtime error 402, must close or hide topmost modal form first, when I call the me.hide on the Form Load of frmProcess.
            Well, I guess that means you're still showing it modally. I don't know, this is sounding quite confusing.

            Um... Let's see, if your current form is displayed modally, then you cannot show a non-modal form until you hide or unload it. Maybe that's the problem. I wouldn't have expected "invalid procedure call" though.

            By the way, if you want to load the form without showing, it just Load frmProcess. There's no need for the Me.Hide.

            Comment

            • Ali Rizwan
              Banned
              Contributor
              • Aug 2007
              • 931

              #7
              Originally posted by Matt Nunnally
              Ali,

              Thanks for the reply. I tried that code. However, if I remove "vbModal" I get an error. Is that what you were suggesting?
              Yeh i am saing to remove vb model.
              Because i am using this statement in my application and i have a large number of code on form1 for form 2

              You can try the code after form.show on load event of form2.

              Comment

              • Ali Rizwan
                Banned
                Contributor
                • Aug 2007
                • 931

                #8
                Originally posted by Matt Nunnally
                Ali,

                Thanks for the reply. I tried that code. However, if I remove "vbModal" I get an error. Is that what you were suggesting?
                Dear Matt
                I tried your code you hae given

                Some code
                frmprocess.show vbModal
                Som code here

                and i see some code here does not work but when i remove vbmodal then some code here works properly
                i have writen this code
                Private Sub Command1_Click( )

                Form1.Caption = "ALI"
                Form2.Show
                Form2.Caption = "ALI"

                End Sub

                Comment

                • Matt Nunnally
                  New Member
                  • Jul 2007
                  • 56

                  #9
                  Originally posted by Killer42
                  Well, I guess that means you're still showing it modally. I don't know, this is sounding quite confusing.

                  Um... Let's see, if your current form is displayed modally, then you cannot show a non-modal form until you hide or unload it. Maybe that's the problem. I wouldn't have expected "invalid procedure call" though.

                  By the way, if you want to load the form without showing, it just Load frmProcess. There's no need for the Me.Hide.
                  This project I'm writing is a plug-in to another application. When my application gets called, there is already another form showing from this other application, which I have no control over. I'm guessing that one is being shown modally.

                  Comment

                  • Matt Nunnally
                    New Member
                    • Jul 2007
                    • 56

                    #10
                    Originally posted by Matt Nunnally

                    Sub Whatever()
                    Some Code Here

                    frmProcess.Show vbModal

                    Some More Code Here

                    end sub

                    I tried moving "Some More Code Here" to the form load of frmProcess. The thing with that is once "Some More Code Here" is done, then I don't need the form up anymore. So putting it on form load never shows the form.
                    I figured out a work around and it works pretty well. from form1 I call frmProcess.show vbModal. On frmProcess, I implemented a Timer and set the click to 1 second. On form load, I enable the Timer. Then in the timer click I put my "Some More Code Here" code and then unload the form when its complete. This allows the form to actually show and completes the code that I want it to.

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Originally posted by Matt Nunnally
                      I figured out a work around and it works pretty well. from form1 I call frmProcess.show vbModal. On frmProcess, I implemented a Timer and set the click to 1 second. On form load, I enable the Timer. Then in the timer click I put my "Some More Code Here" code and then unload the form when its complete. This allows the form to actually show and completes the code that I want it to.
                      Glad to hear you found a way around it. If you are being called from a modal form, then I'm pretty sure it's not possible to show your form non-modally.

                      Comment

                      Working...