- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a set of code that more or less repeats itself and I wonder if a simple set of code could be used to get the appropriate results. I am creating a start part that will have manufacturing limits embedded in the part to prevent the engineer from creating parts outside of these maximums and minimums.
So the control variables are:
minFlange = thick
maxFlange = 80
minWidth = 150
maxWidth =1500
minLength = 288
maxLength = 1806
The parameters I am checking against these maximums and minimums are:
left1
left2
left3
right1
right2
right3
width
length
The basic code that I am writing to catch these variables is:
If left1 < minFlange Then MsgBox ("Oops! That's too small!", "Error Message") left1 = minFlange ElseIf left1 > maxFlange Then MsgBox ("Oops! That's too big!", "Error Message") left1 = maxFlange End If
In the code above, I want to check each of the 8 parameters against the minimums and maximums. Since it clearly looks like the structure of the code will be the same other than the changing variables, I assume a basic routine or function can be written with the different parameters plugged in to get a result for each. However, I have no idea how to write this. Is it possible? How is it done? I use this basic max/min limit in at least 8 different start parts for more than a dozen variables and it causes my code to be clunky and cumbersome to debug. Any help at all would be appreciated.
Solved! Go to Solution.