dcsimg
Results 1 to 10 of 10

Thread: Procedure too long

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2019
    Posts
    5

    Post Procedure too long

    Hi users, Im seeking help as I was told to further Improve my Seniors program and so I have added more line in the coding which result in procedure too long. I have watch online tutorial video on how to use sub script to avoid procedure too long error message to come out but unfortunately I didn't manage to run the program successfully. I hope someone can guide me along on how to split my coding into 2 sub script. attach below is the script
    Attached Files Attached Files

  2. #2
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Re: Procedure too long

    1. Don't use a Word document. If you can't post the code here for whatever reasons, then use a service like Pastebin and share the link here
    2. Since the name of your procedure is CommandButton, it seems more likey that you are actually using VB6 (or VBA??) and not VB.net
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2019
    Posts
    5

    Re: Procedure too long

    1) is sharing link of google docs fine with you?
    2) yes is VBA

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2019
    Posts
    5

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,091

    Re: Procedure too long

    Welcome to VBForums

    Thread moved from the 'VB.Net' forum to the 'Office Development/VBA' forum.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,444

    Re: Procedure too long

    you can break your procedure into blocks in separate procedures then call them all from command 1 in appropriate order

    i guess if i was doing it i would make a block for each worksheet used, remember to take the dimensioning of variables required for each block from the main procedure

    if you need to pass values between blocks you can use arguments for the procedures
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2019
    Posts
    5

    Re: Procedure too long

    alright thanks I will try too at the same time.
    Last edited by CrystalYang; May 9th, 2019 at 07:36 AM. Reason: hide email

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,410

    Re: Procedure too long

    Suggestion - edit your post as fast as you can... if you can, I see you're a new user ... and remove your email address. The forums here are popular and get scanned by scammers and bots and all sorts of manner of low-lifes looking for such nuggets of gold. In addition, it's suggested keeping the conversation here, so that others may also benefit from the experience.

    -tg

    addendum - I'll ask the mods to edit the post to remove your email in case you can't.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2019
    Posts
    5

    Re: Procedure too long

    it's harder than i expected, tell me if im wrong because i tried shifting half of the coding into another sub proc1() but it just couldn't run even though i have dim all the variable. it might be because they are alot of value passing through thats why i couldn't run the program at all

  10. #10
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,444

    Re: Procedure too long

    it might be because they are alot of value passing through thats why i couldn't run the program at all
    that was part of why i suggested using smaller blocks, then you only have to pas values required for lesser amounts of data
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width