I was wondering how the following would work the I saw EVERYCASE:
CASE 1 TO 4: d$ = d$ + MID$(Symbols(1), j, 1)
CASE 2 TO 3: d$ = d$ + MID$(Symbols(1), j, 1)
My idea was this one:
Each 10's digit is basically made up of 3 symbols.
Numbers 1-10 use I, V, X
Numbers 10 - 100 use X, L, C
Numbers 100 - 1000 use C, D, M
The pattern we generate is always the same:
1 = 1st symbol
2 = double 1st symbol
3 = triple 1st symbol
4 = 1st symbol + 2nd symbol
And so on...
So 3 is III. 30 is XXX. 300 is CCC... Same logic pattern, just different symbols based on the 10's position. That's where the DIM Symbols(1 TO 3) array comes from, and represents.
The SELECT EVERY CASE just builds our symbols, to match our values.
CASE 1 TO 4 -- This says we need the first symbol that matches our 10s position, if our number is from 1 to 4.
CASE 2 TO 3 -- does the same, if our number is a 2 or a 3.
CASE 3 -- same, but only if the value is 3.
So if my number is 2, the first case is valid, the second case is valid, but the third case isn't... We build the number II, XX, CC, depending on our 10's position.
So for 22, we just build our value with the XX and then the II, making the answer XXII.
Basically, the SELECT EVERYCASE can be considered to be nothing more than a row of IF statements, all with the same comparison value. The above could also be written as:
IF X >= 1 AND X <= 4 THEN... Do stuff
IF X >= 2 AND X <= 3 THEN... Do stuff
IF X = 3 THEN... Do stuff