Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code procedure size limit

Status
Not open for further replies.

shelspa

Technical User
Dec 13, 2001
66
US
I have written a procedure that is far beyond the 64K size limit. It is in the after update of a field. What to do? Can it be split into multiple procedures?
 
Hi,

Depends on your coding.

You want email it to me to look at?

darrylles@yahoo.co.uk

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
not can, MUST

and not JUST because of the number of characters in the module / procedure. 64K ~=~ 30 pages (for general code sequences), and it has been reasonalbly well demonstrated that the average programmer doesn't do well with individual routines of anywhere near this.

Not all that far ago and long away, many of the structured design 'gurus' recommended that no single 'procedure' should exceed a single page, while others set a limit of 50 lines. I haven't seen these SPECIFIC guidelines recently, but the concept is a basic part of object orientated design.


MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Personally I'd say even 50 lines is too much. Unless I'm using transaction processing, which can be lengthy in some instances, I would try not to exceed 15-20 lines for any one procedure.

A friend of mine writes code for hardware in fighter planes. His organisation works to a maximum of ten lines per proc.

Basic rule of thumb is that one procedure should perform only one task - anymore than that and it can and *should* be split into sub procedures.

Ed Metcalfe. Please do not feed the trolls.....
 
This is not what I wanted to hear. What my code does is determine the min and max of five numbers within a record. It is so long because I have to use if statements for > this and < than that for every possible scenerio. Using the Min and Max functions has been extremely difficult. DMin and Dmax will not work either since these look at all records and not just the current record.
 
If that's ALL your code does, you're using WAY too much code. Tell us more specifically what you're doing (where do the values come from, what gets done with the two values once they're selected) and I'm sure someone here will come up with a way to do that in less than 20 lines of code.

Jeremy =============
Jeremy Wallace
AlphaBet City Dataworks

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Obviously, there is WAY WAY WAY to much code to check the mininum or any of several 'properties' of a set of fields within a record. I cannot even CONCIEVE of having this much code in a MODULE, much less a procedure. You would appear to some remedial thinking about your approach.

One example of finding the mininum of a set of values is:


Code:
Public Function basMinVal(ParamArray varMyVals() As Variant) As Variant

    'Michael Red 10/25/2001
    'To return the MINIMUM or a series of values

    'Sample Usage:
    '? basMinVal(1, 5, 9, 3, 13.663)
    '1

    '?basMinVal(9, 1, 5, 3, 13.663)
    '1

    Dim Idx As Integer
    Dim MyMin As Variant

    If (UBound(varMyVals) < 0) Then
        Exit Function
     Else
        MyMin = varMyVals(0)
    End If

    For Idx = 0 To UBound(varMyVals())
        If (varMyVals(Idx) < MyMin) Then
            MyMin = varMyVals(Idx)
        End If
    Next Idx

    basMinVal = MyMin

End Function



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
shelspa,

Post your code and I will rewrite it for you.

Ed Metcalfe Please do not feed the trolls.....
 
Here is a portion of it to give you an idea. There are five fields and all are from the same table. This code should execute after the fifth field is entered and after each is updated in case the user has to correct data later. I'm sure a min and max function should be able to replace this.

'calculate maximum if all are different
If (Me!Site_1_Thickness.Value > Me!Site_2_Thickness) And (Me!Site_1_Thickness.Value > Me!Site_3_Thickness) And (Me!Site_1_Thickness.Value > Me!Site_4_Thickness) And (Me!Site_1_Thickness.Value > Me!Site_5_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_1_Thickness
End If

If (Me!Site_2_Thickness.Value > Me!Site_1_Thickness) And (Me!Site_2_Thickness.Value > Me!Site_3_Thickness) And (Me!Site_2_Thickness.Value > Me!Site_4_Thickness) And (Me!Site_2_Thickness.Value > Me!Site_5_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_2_Thickness
End If

If (Me!Site_3_Thickness.Value > Me!Site_2_Thickness) And (Me!Site_3_Thickness.Value > Me!Site_1_Thickness) And (Me!Site_3_Thickness.Value > Me!Site_4_Thickness) And (Me!Site_3_Thickness.Value > Me!Site_5_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_3_Thickness
End If

If (Me!Site_4_Thickness.Value > Me!Site_1_Thickness) And (Me!Site_4_Thickness.Value > Me!Site_2_Thickness) And (Me!Site_4_Thickness.Value > Me!Site_3_Thickness) And (Me!Site_4_Thickness.Value > Me!Site_5_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_4_Thickness
End If

If (Me!Site_5_Thickness.Value > Me!Site_1_Thickness) And (Me!Site_5_Thickness.Value > Me!Site_2_Thickness) And (Me!Site_5_Thickness.Value > Me!Site_3_Thickness) And (Me!Site_5_Thickness.Value > Me!Site_4_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_5_Thickness
End If

'for all the same
If (Me!Site_1_Thickness.Value = Me!Site_2_Thickness) And (Me!Site_2_Thickness.Value = Me!Site_3_Thickness) And (Me!Site_3_Thickness.Value = Me!Site_4_Thickness) And (Me!Site_4_Thickness.Value = Me!Site_5_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_1_Thickness
End If

'for 3 same 2 different and the maximum is different
If (Me!Site_2_Thickness.Value = Me!Site_3_Thickness) And (Me!Site_3_Thickness.Value = Me!Site_4_Thickness) And (Me!Site_1_Thickness.Value > Me!Site_5_Thickness) And (Me!Site_5_Thickness.Value > Me!Site_2_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_1_Thickness
End If

If (Me!Site_1_Thickness.Value = Me!Site_3_Thickness) And (Me!Site_3_Thickness.Value = Me!Site_4_Thickness) And (Me!Site_2_Thickness.Value > Me!Site_5_Thickness) And (Me!Site_5_Thickness.Value > Me!Site_1_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_2_Thickness
End If

If (Me!Site_1_Thickness.Value = Me!Site_2_Thickness) And (Me!Site_2_Thickness.Value = Me!Site_4_Thickness) And (Me!Site_3_Thickness.Value > Me!Site_5_Thickness) And (Me!Site_5_Thickness.Value > Me!Site_1_Thickness) Then
Me!Maximum_Thickness.Value = Me!Site_3_Thickness
End If

It continues from here in the same fashion for all scenerios.
 
see basMinVal above?

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top