"Locate" in the program
#5
Right align a number input:
Code: (Select All)
_Title "Right align a number input to a column number" ' b+ 2022-06-08

'expecting numbers up to 10 digits including dot or minus sign for this demo
Locate 5, 10: Print "Number 1:" ' column 19 leave blank if max 10 digits used
Locate 6, 10: Print "Number 2:"
a = getNumber(5, 30)
b = getNumber(6, 30)
t$ = Str$(a + b)
Locate 7, 10: Print "   Total:"
Locate 7, 30 - Len(t$): Print t$

Function getNumber (row, lastDigitCol) ' might need to control length of output
    k$ = InKey$
    While k$ <> Chr$(13)
        If Len(k$) Then
            If InStr("-123456789.", k$) Then
                num$ = num$ + k$
                Locate row, lastDigitCol - Len(num$) - 1: Print Space$(Len(num$));
                Locate row, lastDigitCol - Len(num$): Print num$;
            ElseIf Asc(k$) = 8 Then
                If Len(num$) Then
                    num$ = Left$(num$, Len(num$) - 1)
                    Locate row, lastDigitCol - Len(num$) - 1: Print Space$(Len(num$));
                    Locate row, lastDigitCol - Len(num$): Print num$;
                End If
            End If
        End If
        k$ = InKey$
    Wend
    getNumber = Val(num$)
End Function
b = b + ...
Reply


Messages In This Thread
"Locate" in the program - by Kernelpanic - 06-07-2022, 08:04 PM
RE: "Locate" in the program - by bplus - 06-08-2022, 03:30 PM
RE: "Locate" in the program - by Kernelpanic - 06-08-2022, 05:30 PM
RE: "Locate" in the program - by bplus - 06-08-2022, 06:07 PM
RE: "Locate" in the program - by bplus - 06-08-2022, 07:26 PM
RE: "Locate" in the program - by Kernelpanic - 06-08-2022, 08:39 PM
RE: "Locate" in the program - by RhoSigma - 06-08-2022, 09:49 PM
RE: "Locate" in the program - by Kernelpanic - 06-09-2022, 03:01 PM
RE: "Locate" in the program - by bplus - 06-08-2022, 08:41 PM
RE: "Locate" in the program - by Pete - 06-09-2022, 01:50 AM
RE: "Locate" in the program - by bplus - 06-09-2022, 03:40 AM
RE: "Locate" in the program - by Pete - 06-09-2022, 03:55 AM
RE: "Locate" in the program - by Kernelpanic - 06-09-2022, 03:14 PM
RE: "Locate" in the program - by James D Jarvis - 06-09-2022, 03:16 PM
RE: "Locate" in the program - by Kernelpanic - 06-09-2022, 04:12 PM
RE: "Locate" in the program - by James D Jarvis - 06-09-2022, 04:30 PM
RE: "Locate" in the program - by RhoSigma - 06-09-2022, 07:50 PM
RE: "Locate" in the program - by Kernelpanic - 06-09-2022, 09:16 PM
RE: "Locate" in the program - by Kernelpanic - 06-09-2022, 09:04 PM
RE: "Locate" in the program - by Kernelpanic - 06-09-2022, 04:14 PM
RE: "Locate" in the program - by SMcNeill - 06-10-2022, 04:47 AM
RE: "Locate" in the program - by SMcNeill - 06-10-2022, 05:08 AM
RE: "Locate" in the program - by Kernelpanic - 06-10-2022, 06:29 PM
RE: "Locate" in the program - by bplus - 06-10-2022, 07:42 PM
RE: "Locate" in the program - by Kernelpanic - 06-10-2022, 08:47 PM
RE: "Locate" in the program - by DSMan195276 - 06-10-2022, 11:34 PM
RE: "Locate" in the program - by bplus - 06-10-2022, 09:00 PM
RE: "Locate" in the program - by Kernelpanic - 06-10-2022, 11:15 PM
RE: "Locate" in the program - by Kernelpanic - 06-10-2022, 11:22 PM
RE: "Locate" in the program - by Kernelpanic - 06-10-2022, 11:49 PM
RE: "Locate" in the program - by DSMan195276 - 06-10-2022, 11:57 PM
RE: "Locate" in the program - by bplus - 06-11-2022, 12:10 AM
RE: "Locate" in the program - by Kernelpanic - 06-12-2022, 08:50 PM
RE: "Locate" in the program - by Kernelpanic - 06-12-2022, 08:56 PM
RE: "Locate" in the program - by bplus - 06-12-2022, 09:27 PM
RE: "Locate" in the program - by Kernelpanic - 06-12-2022, 09:54 PM
RE: "Locate" in the program - by bplus - 06-12-2022, 11:16 PM
RE: "Locate" in the program - by Kernelpanic - 06-13-2022, 01:16 PM
RE: "Locate" in the program - by bplus - 06-13-2022, 07:07 PM
RE: "Locate" in the program - by Kernelpanic - 06-13-2022, 08:49 PM
RE: "Locate" in the program - by Pete - 06-14-2022, 06:10 AM



Users browsing this thread: 12 Guest(s)