VB6 Command button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wernerh
    New Member
    • Jul 2007
    • 104

    VB6 Command button

    I have a command button in my application that writes to Excel for report purposes. It has many text boxes in VB app that it populates the Excel spreadsheet with. The problem is that VB gives an error on the volume lines of code against the one command button. It only allows a certain amount of code per button. Is there a way to overcome this issue or to trigger additional code outside that command button code?

    Regards
    Wernerh
    Last edited by Killer42; Nov 13 '07, 06:41 AM.
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    As such there is no limitation for number of lines in a Sub procedure, but it can contain only 64K of code. If the procedure exceeds the limit, a compile-time error is generated.
    Again there is no limitation on the number of procedures in a module, so you can break up one big procedure into smaller procedures and call them.

    Regards
    Veena
    Last edited by Killer42; Nov 13 '07, 06:42 AM.

    Comment

    • Wernerh
      New Member
      • Jul 2007
      • 104

      #3
      Originally posted by QVeen72
      Hi,

      As such there is no limitation for number of lines in a Sub procedure, but it can contain only 64K of code. If the procedure exceeds the limit, a compile-time error is generated.
      Again there is no limitation on the number of procedures in a module, so you can break up one big procedure into smaller procedures and call them.

      Regards
      Veena
      Hi Veena
      Yes, then my procedure is exceeding the 64k as you have stiplulated. Could you please give me an example of how to call a secondary procedure to follow on on the first procedure or direct me to literture that could assist. It would be appreciated.


      Thanks
      Werner

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        You have One Huge Procedure in Some Command_Click,
        say,
        Private Sub MyCmd_Click()

        First Rename "MyCmd_Clic k" that to "MyProc1()"
        After some 2000 Lines add an "End Sub"

        Next Line add "Private Sub MyProc2()
        Again After 2000 Lines add an End Sub

        Repeat until you are finished with all the Lines..

        And in actual Command Click event..

        [code=vb]
        Private Sub MyCmd_Click()
        Call MyProc1
        Call MyProc2
        Call MyProc3
        '.....
        Call MyProc20
        End Sub
        [code]

        Before doing anything, Keep a Back-Up of your Form ...

        Regards
        Veena

        Comment

        • Wernerh
          New Member
          • Jul 2007
          • 104

          #5
          Originally posted by QVeen72
          Hi,

          You have One Huge Procedure in Some Command_Click,
          say,
          Private Sub MyCmd_Click()

          First Rename "MyCmd_Clic k" that to "MyProc1()"
          After some 2000 Lines add an "End Sub"

          Next Line add "Private Sub MyProc2()
          Again After 2000 Lines add an End Sub

          Repeat until you are finished with all the Lines..

          And in actual Command Click event..

          [code=vb]
          Private Sub MyCmd_Click()
          Call MyProc1
          Call MyProc2
          Call MyProc3
          '.....
          Call MyProc20
          End Sub
          [code]

          Before doing anything, Keep a Back-Up of your Form ...

          Regards
          Veena

          Thank you so much, just did it now and it works perfectly. Thanks again for the help

          Werner

          Comment

          Working...