Consulting

Results 1 to 20 of 20

Thread: A function that crashes: Compile Error: Procedure too large

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    First: I notice that you declare ChxLangue As Byte. Since the only reason to use Bytes is to conserve memory usage and since only one value of ChxLangue is used at a time. I would declare it as an Integer. (Bytes are limited to only 254 positive integers)

    As to that Too Long Procedure, I would break Select CaseChxLangue into several smaller Functions
    Select Case ChxLangue
       Case 1 to 50: LangueRef = ChxLangue1_50(ChxLangue)
       Case 51 to 100: LangueRef = ChxLangue51_100(ChxLangue)
       Case Etc
       Case Esle: LangueRef = "Unknown"
    End Select
    Function ChxLangue1_50(ChxLangue as Long) As Variant
    Select Case ChxLangue
       Case 1: Langue = XLangue
       Etc:
       Case 50: Langue = YLangue
    End Select
    End Function
    Function XLangue() As Variant
       XLangue = Array(ChrW(1040) & ChrW(1084) & ChrW(1213) & ChrW(1100) & ChrW(1231) & ChrW(1096), _
                                   ChrW(1040) & ChrW(1096) & ChrW(1241) & ChrW(1072) & ChrW(1093) & ChrW(1100), _
                                   ChrW(1040) & ChrW(1193) & ChrW(1072) & ChrW(1096), _
                                   ChrW(1040) & ChrW(1093) & ChrW(1072) & ChrW(1096), _
                                   ChrW(1040) & ChrW(1191) & ChrW(1096) & ChrW(1100) & ChrW(1072) & ChrW(1096), _
                                   ChrW(1040) & ChrW(1093) & ChrW(1241) & ChrW(1072) & ChrW(1096), _
                                   ChrW(1040) & ChrW(1089) & ChrW(1072) & ChrW(1073) & ChrW(1096), "Abkhaze")
    
    End Function
    Function YLangue() As Variant
       YLangue  = Array("Sennedei", "Monnendei", "Tirsdei", "Winsdei", "Türsdei", "Frideisennin", "Sennin", "Frisien (Nord)")
    End Function
    Since the various XLangue and YLangue Functions don't Have to be in the same module as NomJourSemaineTrip, think about separating them into Modules named after Language Families or even Continents Anything that makes adding, editing and maintaining them easier. I would keep the "ChxLangue1_50," "ChxLangue51_100" Etc Functions in the same module as NomJourSemaineTrip

    BTW, I would use real descriptive names for those Functions, like "FrenchWeekDays," "LangueEnglish," "TagalogLangue," etc. Instead of using "Magic Numbers" to reference languages, I would at least use an Enum.
    Last edited by SamT; 03-30-2021 at 07:07 AM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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