Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Correcting the code
#12
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?
Reply


Messages In This Thread
Correcting the code - by Chris - 10-27-2023, 07:19 PM
RE: Correcting the code - by bplus - 10-27-2023, 08:28 PM
RE: Correcting the code - by SMcNeill - 10-27-2023, 09:31 PM
RE: Correcting the code - by Chris - 10-28-2023, 06:34 AM
RE: Correcting the code - by SMcNeill - 10-28-2023, 01:46 PM
RE: Correcting the code - by Stuart - 10-28-2023, 10:43 AM
RE: Correcting the code - by Chris - 10-28-2023, 11:34 AM
RE: Correcting the code - by Chris - 10-28-2023, 11:49 AM
RE: Correcting the code - by bplus - 10-28-2023, 12:55 PM
RE: Correcting the code - by Chris - 10-28-2023, 02:13 PM
RE: Correcting the code - by bplus - 10-28-2023, 02:46 PM
RE: Correcting the code - by SMcNeill - 10-28-2023, 06:18 PM
RE: Correcting the code - by Chris - 10-28-2023, 07:44 PM
RE: Correcting the code - by bplus - 10-28-2023, 07:47 PM
RE: Correcting the code - by SMcNeill - 10-28-2023, 09:48 PM
RE: Correcting the code - by bplus - 10-28-2023, 07:51 PM



Users browsing this thread: 16 Guest(s)