10-12-2025, 01:18 PM
One thing of note -- this is the incorrect usage of MID$ for what you want to do:
a$ = "apples pears"
If Mid$(a$, 7) = " " Then
Notice that you're not telling it how many spaces you want from that string, so what you're basically saying is:
Go to the middle of the string, start at the 7th position, and return the rest of the string.
Mid$(a$, 7) = " pears"
What you actually wanted here was this usage:
If Mid$(a$, 7, 1) = " " Then
Notice that you're now telling it how many spaces you want from that string, so what you're basically saying is:
Go to the middle of the string, start at the 7th position, and return one character from the string.
Missed parameter = missed result.
That said; use the ASC version anyway, when you ever can. It's much faster. String comparison and manipulation is rather slow, but we do numeric ASCII compares quite effiicently.
a$ = "apples pears"
If Mid$(a$, 7) = " " Then
Notice that you're not telling it how many spaces you want from that string, so what you're basically saying is:
Go to the middle of the string, start at the 7th position, and return the rest of the string.
Mid$(a$, 7) = " pears"
What you actually wanted here was this usage:
If Mid$(a$, 7, 1) = " " Then
Notice that you're now telling it how many spaces you want from that string, so what you're basically saying is:
Go to the middle of the string, start at the 7th position, and return one character from the string.
Missed parameter = missed result.

That said; use the ASC version anyway, when you ever can. It's much faster. String comparison and manipulation is rather slow, but we do numeric ASCII compares quite effiicently.

