"Locate" in the program
#21
Seems to me that some of the obscure commands would be whatyou want. VIEW, VIEW PORT, WINDOW... some of those, but my memory isn't supplying which is what, at the moment. LOL
Reply
#22
Honestly though, I'd think the easiest way to do something like this would be to just write a simple function to handle the indentation for you.

Code: (Select All)
Print TB(5); "Name"; TB(10); "Steve the Amazing!"
Print TB(5); "Age"; TB(10); "Old Enough to know better."
Print TB(5); "Sex"; TB(10); "Not often enough!"


Function TB$ (spaces) 'tab spaces without
    x = Pos(0)
    If x > spaces Then Print
    Locate , spaces
End Function

The above is a very simple little tab routine which advances text to the breakpoint which we desire with our printing for quick formatting and spacing.  Wink
Reply
#23
@SMcNeill - Unfortunately that does not work. The correct formatting remains the problem.

At least so it will compiled.
Code: (Select All)
'TAB-Versuch, nach Vorlage SMcNeill - 10. Juni 2022

OPTION _EXPLICIT

Declare TB(spaces as integer)

DIM ProductMaterial, IndirectCost, MaterialCost AS DOUBLE

PRINT TB(5);
INPUT "Production material       : ", ProductMaterial

IndirectCost = (ProductMaterial * 8) / 100
PRINT TB(5);
PRINT USING "Indirect material cost    : ###,###.##"; IndirectCost

MaterialCost = ProductMaterial + IndirectCost
PRINT TB(5);
PRINT USING "Material costs            : ###,###.##"; MaterialCost

FUNCTION TB (spaces) 'tab spaces without
  DIM x AS INTEGER

  x = POS(0)
  IF x > spaces THEN PRINT
  LOCATE , spaces
END FUNCTION

[Image: TAB-Versuch2022-06-10.jpg]
Reply
#24
OK everything aligns:


Code: (Select All)
Option _Explicit
Dim As Double ProductMaterial, IndirectCost, MaterialCost

ProductMaterial = getNumber(10, 23, "Production material")
'Input "Production material      : ",

IndirectCost = (ProductMaterial * 8) / 100
PU 11, 23, "Indirect material cost", IndirectCost

MaterialCost = ProductMaterial + IndirectCost
PU 12, 23, "Material costs", MaterialCost

Sub PU (row, col, label$, number As Double) ' label needs to be 25 chars max
    Dim buf$
    Locate row, col
    buf$ = Space$(25)
    Mid$(buf$, 1) = label$
    Print Using buf$ + ": ###,###.##"; number
End Sub

Function getNumber# (row, col, prompt25$) ' might need to control length of output
    Dim K$, num$
    Locate row, col: Print prompt25$; "? "
    K$ = InKey$
    While K$ <> Chr$(13)
        If Len(K$) Then
            If InStr("-123456789.", K$) Then
                num$ = num$ + K$
                PU row, col, prompt25$, Val(num$)
            ElseIf Asc(K$) = 8 Then
                If Len(num$) Then
                    num$ = Left$(num$, Len(num$) - 1)
                    PU row, col, prompt25$, Val(num$)
                End If
            End If
        End If
        K$ = InKey$
    Wend
    getNumber# = Val(num$)
End Function

   
b = b + ...
Reply
#25
@bplus - Thanks for your effort, . . . on the screenshot you can see where the problem is.

The entries can vary between, for example: 877.00 and 820,888.00 or 2,450,780.67 and more.

In VisualBasic I only had to consider the text field for the possible size of the input and output, but everything was then right justified. Unfortunately, I didn't take any screenshots back then (a picture says more than thousand words).

Unfortunately I only have VB 3.0 Prof on floppy disk and #4 was from a friend Cool , but I can't find the CD anymore. When trying to load the versions from the web, it only led to dubious sites.


[Image: Locate-bplus2022-06-10-224138.jpg]
Reply
#26
Just extend the print using to #,###,###.00 or use #,###,###,###.00 if billion $
Code: (Select All)
Sub PU (row, col, label$, number As Double) ' label needs to be 25 chars max
    Dim buf$
    Locate row, col
    buf$ = Space$(25)
    Mid$(buf$, 1) = label$
    Print Using buf$ + ": #,###,###,###.00"; number
End Sub
I only used ###,###.## because that is what you used!

GetNumber() is right aligned input.

Even with VB or any GUI you need to allow for maximum number.
b = b + ...
Reply
#27
You're right about that, but does it look as correct as in this examples?

[Image: bplus-BSP-Vorschlag.jpg]

And so it was it in Visual Basic (Example):

[Image: QB64-Formatierung.jpg]
Reply
#28
For those who care, that's the guide:

[Image: Angebotskalkulation-Buchauszug.jpg]

And this is the book:

[Image: Industriebuchf-hrung.jpg]
Reply
#29
(06-10-2022, 08:47 PM)Kernelpanic Wrote: Thanks for your effort, . . . on the screenshot you can see where the problem is.

Would you mind clarifying how you got that exactly? It looks kinda like a bug, but I tried just printing
1400
directly and it seems to work as expected, so I'm wondering what you did different:

[Image: Capture.png]
Reply
#30
I typed 14 . . . and then came automatically 14.00

I've tried several times, always with the same result.

I have no explanation for this. - Except there's a bug somewhere in the program. - Since I didn't write it myself. . . I would have to go through the program step by step.

But not today! No!
Reply




Users browsing this thread: 2 Guest(s)