Re: How to simplify long syntax



See the two inline comments/questions....

'Case 1 : 25 000

Select Case Mid(TxtSheetNo, 5, 1) 'AA11A - ZZ44D

'Case 5 char X min & max

Case "A", "C"
Xmin = Xmin
Xmax = Xmin + 12500

Case "B", "D"
Xmin = Xmin + 12500
Xmax = Xmin + 12500

End Select

Select Case Mid(TxtSheetNo, 5, 1) 'AA11A - ZZ44D

'Case 5 char Y min & max

Case "A", "B"
Ymin = Ymin
Ymax = Ymin + 12500

Case "C", "D"
Ymin = Ymin + 12500
Ymax = Ymin + 12500

End Select
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Since there is a test following the above one for character positions 5 and 6, the natural question for the above Select Case test is this.... if character position 5 is a letter ("A" through "D"), and the test when it is a letter is for character position 5 only, then what is in character position 6 for this case... a blank?



''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Case 1 : 5000

Select Case Mid(TxtSheetNo, 7, 1) 'AA11001 - ZZ44244

'Case 7 char X min & max

Case "1", "3"
Xmin = Xmin
Xmax = Xmin + 2500

Case "2", "4"
Xmin = Xmin + 2500
Xmax = Xmin + 2500

End Select

Select Case Mid(TxtSheetNo, 7, 1) 'AA11001 - ZZ44244

'Case 7 char Y min & max

Case "1", "2"
Ymin = Ymin
Ymax = Ymin + 2500

Case "3", "4"
Ymin = Ymin + 2500
Ymax = Ymin + 2500

End Select

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Case 1 : 1000

Select Case Mid(TxtSheetNo, 7, 2) 'AA110000 - ZZ442499

'Case 7&8 char Xmin & max

Case "00", "10", "20", "30", "40", "50", "60", "70", "80", "90"
Xmin = Xmin
Xmax = Xmin + 500

Case "01", "11", "21", "31", "41", "51", "61", "71", "81", "91"
Xmin = Xmin + 500
Xmax = Xmin + 500

Case "02", "12", "22", "32", "42", "52", "62", "72", "82", "92"
Xmin = Xmin + 1000
Xmax = Xmin + 500

Case "03", "13", "23", "33", "43", "53", "63", "73", "83", "93"
Xmin = Xmin + 1500
Xmax = Xmin + 500

Case "04", "14", "24", "34", "44", "54", "64", "74", "84", "94"
Xmin = Xmin + 2000
Xmax = Xmin + 500

Case "05", "15", "25", "35", "45", "55", "65", "75", "85", "95"
Xmin = Xmin + 2500
Xmax = Xmin + 500

Case "06", "16", "26", "36", "46", "56", "66", "76", "86", "96"
Xmin = Xmin + 3000
Xmax = Xmin + 500

Case "07", "17", "27", "37", "47", "57", "67", "77", "87", "97"
Xmin = Xmin + 3500
Xmax = Xmin + 500

Case "08", "18", "28", "38", "48", "58", "68", "78", "88", "98"
Xmin = Xmin + 4000
Xmax = Xmin + 500

Case "09", "19", "29", "39", "49", "59", "69", "79", "89", "99"
Xmin = Xmin + 4500
Xmax = Xmin + 500

End Select

Select Case Mid(TxtSheetNo, 7, 2) 'AA110000 - ZZ442499

'Case 7&8 char Y min & max

Case "00", "01", "02", "03", "04", "05", "06", "07", "08", "09"
Ymin = Ymin
Ymax = Ymin + 500

Case "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"
Ymin = Ymin + 500
Ymax = Ymin + 500

Case "20", "21", "22", "23", "24", "25", "26", "27", "28", "29"
Ymin = Ymin + 1000
Ymax = Ymin + 500

Case "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"
Ymin = Ymin + 1500
Ymax = Ymin + 500

Case "40", "41", "42", "43", "44", "45", "46", "47", "48", "49"
Ymin = Ymin + 2000
Ymax = Ymin + 500

Case "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"
Ymin = Ymin + 2500
Ymax = Ymin + 500

Case "60", "61", "62", "63", "64", "65", "66", "67", "68", "69"
Ymin = Ymin + 3000
Ymax = Ymin + 500

Case "70", "71", "72", "73", "74", "75", "76", "77", "78", "79"
Ymin = Ymin + 3500
Ymax = Ymin + 500

Case "80", "81", "82", "83", "84", "85", "86", "87", "88", "89"
Ymin = Ymin + 4000
Ymax = Ymin + 500

Case "90", "91", "92", "93", "94", "95", "96", "97", "98", "99"
Ymin = Ymin + 4500
Ymax = Ymin + 500

End Select
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

The order you have the above two test in will produce incorrect results. Think about it... if the were, say, "23", where you would want to apply the second test, that second test will never be reached. Why? Because the "2" from the "23" will pass the first test condition and be handled there. This leads to the same question as earlier... if you are only meaning to test for a single digit (1-4) in character position 7, then what is in character position 8 at that time... a blank?


Rick

.