10-28-2023, 06:18 PM
Code: (Select All)
Do
Print "Input the correct value, by the rules! =>";
Do
a$ = Input$(1)
Select Case a$
Case "0" To "7"
If Len(num$) < 7 Then Print a$;: num$ = num$ + a$
Case Chr$(8) 'backspace
If Len(num$) > 0 Then
L = Pos(0) - 1
num$ = Left$(num$, Len(num$) - 1)
Locate , L: Print " "; 'erase the character
Locate , L: 'move the cursor back a spot
End If
Case Chr$(13) 'enter
If Len(num$) Then finished = -1 'if less than 7 digits, enter confirms
Case Chr$(27) 'escape
System
End Select
Loop Until finished Or Len(num$) = 7
Print
Print "Your number as entereed was: "; num$
finished = 0: num$ = "" 'reset the variables
Loop 'forever and ever and ever... or until you hit the big red X to close the program.
So here's a question: What happens if someone hits 00123? Does that count as 123? Is it valid? Or is it 0? Is the 0 *only* valid when by itself? Or can it be preceeding other numbers? What you're wanting isn't hard to do. Figuring out the RULES of what's acceptable and what isn't, is what's hard to account for in this case. LOL!
What happens with? 0<enter> --- this is 0. Correct?
00123<enter> -- is this valid, or should that 123 automatically erase those leading zeros to make 123? Or should it stay 00123?
0123456 -- does this count as a 7 digit value? Or should this be 6, with that zero not possible?