I may have played with functions back in the 80s and 90s, but they aren't part of my coding repertoire now.  Still, I understand what they do, and so I thought I'd try out this latest suggestion first, based on people's comments.
Test program below:
-   
-   
- answer$ = Limit$("Are you M)ale or F)emale? ", "MFmf") 
- 'answer$ = Limit$("Enter a number from 1 to 5", "12345" 
-   
- Print "Answer= "- ; answer$ 
 
For simplicity, I ran it under QB45, running on a Linux machine.
Two things:
1) In "editor" mode, the program appeared to consist solely of the final three lines -- in other words, the function definition was missing.  I assume that this is normal, but doesn't it make editing and de-bugging rather difficult?
2) Second, when run, the program displayed an "argument-count mismatch" error, with "Limit$" highlighted, on this line:
I've attached a screenshot to this message.
Any thoughts, anyone?  It's not a showstopper, as I can switch to one of the other methods.  I just thought I'd try this one first.
Malcolm