Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Correcting the code
#8
@Chris what do you want to happen when someone just hits the enter key, no number started?

If you don't want zero what do you want? an error message? and empty string? just ignore? You didn't say.

And really you might just code it yourself, in fact code each scenario for practice.

IF B$ = CHR$(13) AND H$ = "" THEN ' do what you want!

We got most of work done for you already, be a coder yourself Smile

Also YOU CAN make this a little fancier by adding a backspace button so a person can edit es number before it is "returned".

Oh I should warn if H$ = "" empty string then Val(H$) = 0 automatically unless you tell it to do something else for H$ = "" before VAL(H$)


Update I like all if's under one roof, it's more efficient:
Code: (Select All)
H$ = "": B$ = ""
While Len(H$) < 7
    Locate 1, 1: Print Spc(8)
    Locate 1, 1: Print H$
    B$ = ""
    While B$ = ""
        B$ = InKey$
        _Limit 30
    Wend
    If B$ = Chr$(27) Then
        End
    ElseIf B$ = "-" Then
        If H$ = "" Then H$ = "-" Else Beep
    ElseIf InStr("0123456789", B$) Then
        H$ = H$ + B$
    ElseIf B$ = Chr$(13) And H$ = "" Then
        Beep
    ElseIf B$ = Chr$(13) And H$ <> "" Then
        Exit While
    End If
    _Limit 30
Wend
H! = Val(H$): Print "H ="; H!
I chose BEEP when H$="" and B$ = enter
b = b + ...
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: 3 Guest(s)