Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Locate" in the program
#31
I think I see it, It's doing `InStr("-123456789.", K$)` to determine if the entered character is a digit. It's missing '0' in the valid digit check, so you can't type it in Big Grin
Reply
#32
Oops!

For a second I thought it was the .00 instead of .## that I changed.

Wait so a 0 was missed! ;-))

I think this little exercise has me thinking about doing textBoxes and redoing listBoxes along with buttons for a really simple GUI.
b = b + ...
Reply
#33
After input the "Herstellkosten" I get an error message that I can't explain. There is a problem between lines 122 and 137 from there; see the screenshot.

The calculation is correct, as is the output.

[Image: Angebot-Fehler122-2022-06-12-214130.jpg]
Reply
#34
Oops, one can only upload one image at a time.  Huh

PS:
I changed the name of the "SUB PU" to understand what is happening. And I added the same SUB "AusPlatz" for the output. In the screenshot you can see why.
[Image: Zeile122-137-2022-06-12.jpg]
Reply
#35
Line 122 says
Locate 40, 3

Do you have 40 rows to print on?
I can't tell because the code is not posted so I can't tell which screen you are using. But that would be my guess to the error.
b = b + ...
Reply
#36
That is the code (I also tested it with: "buf$ = Space$(45)":

Code: (Select All)
'Zuschlags- bzw. Angebotskalkulation. Aus Industriebuchfuehrung S.267 - 7. Juni 2022
'Formattierung von "bplus", 10 Juni 2022

'Subroutine: EinPlatz, fuer Eingabe und Platzierung
'Dasselbe fuer die lange Ausgabe : AusPlatz
'11. Juni 2022 - Kernelpanic

Option _Explicit

Dim Fertigungsmaterial, Materialgemeinkosten As Double
Dim FertigungsloehneI, FertigungsgemeinkostenI As Double
Dim FertigungsloehneII, FertigungsgemeinkostenII As Double

Dim fertMaterialkosten, fertFertigungskosten1, fertFertigungskosten2 As Double

Dim Herstellkosten, Verwaltungsgemeinkosten, Vertriebskosten As Double
Dim Selbstkosten As Double

'Kalkulatorischer Gewinnzuschlag
'(Betriebsgewinn * 100%) / Allg. Selbstkosten -- Man kann 20% annehmen.
Dim Gewinnzuschlag As Double

'Annehmen als 95%
Dim Barverkaufspreis As Double

Dim Kundenskonto, Vertreterprovision As Double

'Annehmen als 90%
Dim Zielverkaufspreis As Double

Dim Kundenrabatt, Listenpreis As Double

Screen _NewImage(800, 600, 32)

Print
Print Tab(15); "Angebotskalkulation"
Print Tab(15); "-------------------"
Print

'Eingabe, Entspricht: Locate 5, 2
Fertigungsmaterial = getNumber(5, 3, "Fertigungsmaterial")

'Materialgemeinkosten + 8% auf Fertigungsmaterial
Materialgemeinkosten = (Fertigungsmaterial * 8) / 100
EinPlatz 6, 3, "+ 8% Gemeinkosten: ", Materialgemeinkosten
Locate 7, 3
Print "--------------------------------------------------"

'Matarialkosten gesamt
fertMaterialkosten = ((Fertigungsmaterial * 8) / 100) + Fertigungsmaterial

AusPlatz 8, 3, "Die Materialkosten betragen insgesamt", fertMaterialkosten

'Eingabe
FertigungsloehneI = getNumber(10, 3, "Fertigungsloehne I")

'Fertigungsgemeinkosten I +110%
FertigungsgemeinkostenI = (FertigungsloehneI * 110) / 100
EinPlatz 11, 3, "+ 110% Fertigungsgemeinkosten", FertigungsgemeinkostenI
Locate 12, 3
Print "--------------------------------------------------"

fertFertigungskosten1 = FertigungsloehneI + FertigungsgemeinkostenI
AusPlatz 14, 3, "Die Fertigungskosten 1 betragen", fertFertigungskosten1

'Eingabe
FertigungsloehneII = getNumber(16, 3, "Fertigungsloehne II")

'Fertigungsgemeinkosten II +120%
FertigungsgemeinkostenII = (FertigungsloehneII * 120) / 100
EinPlatz 17, 3, "+ 120% Fertigungsgemeinkosten", FertigungsgemeinkostenII
Locate 18, 3
Print "--------------------------------------------------"

fertFertigungskosten2 = FertigungsloehneII + FertigungsgemeinkostenII
AusPlatz 20, 3, "Die Fertigungskosten 2 betragen", fertFertigungskosten2

'Eingabe
Herstellkosten = getNumber(22, 3, "Herstellkosten")
'EinPlatz 18, 2, "Herstellkosten:", Herstellkosten: PRINT

'Verwaltungsgemeinkosten +20%
Verwaltungsgemeinkosten = (Herstellkosten * 20) / 100
EinPlatz 23, 3, "+ 20% Verwaltungsgemeinkosten", Verwaltungsgemeinkosten

'Vertriebskosten +4%
Vertriebskosten = (Herstellkosten * 4) / 100
EinPlatz 24, 3, "+ 4% Vertriebskosten", Vertriebskosten
Locate 25, 3
Print "--------------------------------------------------"

Selbstkosten = (Herstellkosten + Verwaltungsgemeinkosten) + Vertriebskosten
AusPlatz 26, 3, "Die Selbstkosten des Auftrags betragen", Selbstkosten

'#Kalkulatorischer Gewinnzuschlag
'Betriebsgewinn * 100%) / Allg. Selbstkosten -- Man kann 20% annehmen.
Gewinnzuschlag = (Selbstkosten * 20) / 100
AusPlatz 28, 3, "+ 20% Gewinnzuschlag", Gewinnzuschlag

'Barverkaufspreis: Annehmen als 95%
Barverkaufspreis = Selbstkosten + Gewinnzuschlag
AusPlatz 30, 3, "Barverkaufspreis (als 95% annehmen)", Barverkaufspreis

'Kundenskonto 2% und Vertreterprovision 3%
Kundenskonto = (Barverkaufspreis * 2) / 95
AusPlatz 31, 3, "+ 2% Kundenskonto", Kundenskonto

Vertreterprovision = (Barverkaufspreis * 3) / 95
AusPlatz 32, 3, "+ 3% Vertreterprovision", Vertreterprovision
Locate 33, 3
Print "----------------------------------------------------------"

Zielverkaufspreis = (Barverkaufspreis + Kundenskonto) + Vertreterprovision
AusPlatz 34, 3, "Zielverkaufspreis", Zielverkaufspreis

'Kundenrabatt: Annehmen als 90%
Kundenrabatt = (Zielverkaufspreis * 10) / 90
AusPlatz 36, 3, "+ 10% Kundenrabatt", Kundenrabatt
Locate 37, 3
Print "----------------------------------------------------------"

Listenpreis = (Zielverkaufspreis + Kundenrabatt)
AusPlatz 39, 3, "Listenpreis", Listenpreis
Locate 40, 3
Print "#############################################################"

End 'Hauptprogramm

Sub EinPlatz (row, col, label$, number As Double) 'Eingabe darf maximal 25 Zeichen betragen
  Dim buf$
  Locate row, col
  buf$ = Space$(30)
  Mid$(buf$, 1) = label$
  Print Using buf$ + ": ###,###,###,###.##"; number
End Sub

Sub AusPlatz (row, col, label$, number As Double) 'Fuer extra Ausgabe
  Dim buf$
  Locate row, col
  buf$ = Space$(45) '40 Zeichen lang
  Mid$(buf$, 1) = label$
  Print Using buf$ + ": ###,###,###,###.##"; number
End Sub


Function getNumber# (row, col, prompt25$) 'Laenge der Ausgabe steuern
  Dim K$, num$
  Locate row, col: Print prompt25$; "? "
  K$ = InKey$
  While K$ <> Chr$(13)
    If Len(K$) Then
      'Fuer Nachkommastelle muss "." gedrueckt werden
      If InStr("-0123456789.", K$) Then
        num$ = num$ + K$
        EinPlatz row, col, prompt25$, Val(num$)
      ElseIf Asc(K$) = 8 Then
        If Len(num$) Then
          num$ = Left$(num$, Len(num$) - 1)
          EinPlatz row, col, prompt25$, Val(num$)
        End If
      End If
    End If
    K$ = InKey$
  Wend
  getNumber# = Val(num$)
End Function
Reply
#37
(06-12-2022, 09:54 PM)Kernelpanic Wrote: That is the code (I also tested it with: "buf$ = Space$(45)":

Code: (Select All)
'Zuschlags- bzw. Angebotskalkulation. Aus Industriebuchfuehrung S.267 - 7. Juni 2022
'Formattierung von "bplus", 10 Juni 2022

'Subroutine: EinPlatz, fuer Eingabe und Platzierung
'Dasselbe fuer die lange Ausgabe : AusPlatz
'11. Juni 2022 - Kernelpanic

Option _Explicit

Dim Fertigungsmaterial, Materialgemeinkosten As Double
Dim FertigungsloehneI, FertigungsgemeinkostenI As Double
Dim FertigungsloehneII, FertigungsgemeinkostenII As Double

Dim fertMaterialkosten, fertFertigungskosten1, fertFertigungskosten2 As Double

Dim Herstellkosten, Verwaltungsgemeinkosten, Vertriebskosten As Double
Dim Selbstkosten As Double

'Kalkulatorischer Gewinnzuschlag
'(Betriebsgewinn * 100%) / Allg. Selbstkosten -- Man kann 20% annehmen.
Dim Gewinnzuschlag As Double

'Annehmen als 95%
Dim Barverkaufspreis As Double

Dim Kundenskonto, Vertreterprovision As Double

'Annehmen als 90%
Dim Zielverkaufspreis As Double

Dim Kundenrabatt, Listenpreis As Double

Screen _NewImage(800, 600, 32)

Print
Print Tab(15); "Angebotskalkulation"
Print Tab(15); "-------------------"
Print

'Eingabe, Entspricht: Locate 5, 2
Fertigungsmaterial = getNumber(5, 3, "Fertigungsmaterial")

'Materialgemeinkosten + 8% auf Fertigungsmaterial
Materialgemeinkosten = (Fertigungsmaterial * 8) / 100
EinPlatz 6, 3, "+ 8% Gemeinkosten: ", Materialgemeinkosten
Locate 7, 3
Print "--------------------------------------------------"

'Matarialkosten gesamt
fertMaterialkosten = ((Fertigungsmaterial * 8) / 100) + Fertigungsmaterial

AusPlatz 8, 3, "Die Materialkosten betragen insgesamt", fertMaterialkosten

'Eingabe
FertigungsloehneI = getNumber(10, 3, "Fertigungsloehne I")

'Fertigungsgemeinkosten I +110%
FertigungsgemeinkostenI = (FertigungsloehneI * 110) / 100
EinPlatz 11, 3, "+ 110% Fertigungsgemeinkosten", FertigungsgemeinkostenI
Locate 12, 3
Print "--------------------------------------------------"

fertFertigungskosten1 = FertigungsloehneI + FertigungsgemeinkostenI
AusPlatz 14, 3, "Die Fertigungskosten 1 betragen", fertFertigungskosten1

'Eingabe
FertigungsloehneII = getNumber(16, 3, "Fertigungsloehne II")

'Fertigungsgemeinkosten II +120%
FertigungsgemeinkostenII = (FertigungsloehneII * 120) / 100
EinPlatz 17, 3, "+ 120% Fertigungsgemeinkosten", FertigungsgemeinkostenII
Locate 18, 3
Print "--------------------------------------------------"

fertFertigungskosten2 = FertigungsloehneII + FertigungsgemeinkostenII
AusPlatz 20, 3, "Die Fertigungskosten 2 betragen", fertFertigungskosten2

'Eingabe
Herstellkosten = getNumber(22, 3, "Herstellkosten")
'EinPlatz 18, 2, "Herstellkosten:", Herstellkosten: PRINT

'Verwaltungsgemeinkosten +20%
Verwaltungsgemeinkosten = (Herstellkosten * 20) / 100
EinPlatz 23, 3, "+ 20% Verwaltungsgemeinkosten", Verwaltungsgemeinkosten

'Vertriebskosten +4%
Vertriebskosten = (Herstellkosten * 4) / 100
EinPlatz 24, 3, "+ 4% Vertriebskosten", Vertriebskosten
Locate 25, 3
Print "--------------------------------------------------"

Selbstkosten = (Herstellkosten + Verwaltungsgemeinkosten) + Vertriebskosten
AusPlatz 26, 3, "Die Selbstkosten des Auftrags betragen", Selbstkosten

'#Kalkulatorischer Gewinnzuschlag
'Betriebsgewinn * 100%) / Allg. Selbstkosten -- Man kann 20% annehmen.
Gewinnzuschlag = (Selbstkosten * 20) / 100
AusPlatz 28, 3, "+ 20% Gewinnzuschlag", Gewinnzuschlag

'Barverkaufspreis: Annehmen als 95%
Barverkaufspreis = Selbstkosten + Gewinnzuschlag
AusPlatz 30, 3, "Barverkaufspreis (als 95% annehmen)", Barverkaufspreis

'Kundenskonto 2% und Vertreterprovision 3%
Kundenskonto = (Barverkaufspreis * 2) / 95
AusPlatz 31, 3, "+ 2% Kundenskonto", Kundenskonto

Vertreterprovision = (Barverkaufspreis * 3) / 95
AusPlatz 32, 3, "+ 3% Vertreterprovision", Vertreterprovision
Locate 33, 3
Print "----------------------------------------------------------"

Zielverkaufspreis = (Barverkaufspreis + Kundenskonto) + Vertreterprovision
AusPlatz 34, 3, "Zielverkaufspreis", Zielverkaufspreis

'Kundenrabatt: Annehmen als 90%
Kundenrabatt = (Zielverkaufspreis * 10) / 90
AusPlatz 36, 3, "+ 10% Kundenrabatt", Kundenrabatt
Locate 37, 3
Print "----------------------------------------------------------"

Listenpreis = (Zielverkaufspreis + Kundenrabatt)
AusPlatz 39, 3, "Listenpreis", Listenpreis
Locate 40, 3
Print "#############################################################"

End 'Hauptprogramm

Sub EinPlatz (row, col, label$, number As Double) 'Eingabe darf maximal 25 Zeichen betragen
  Dim buf$
  Locate row, col
  buf$ = Space$(30)
  Mid$(buf$, 1) = label$
  Print Using buf$ + ": ###,###,###,###.##"; number
End Sub

Sub AusPlatz (row, col, label$, number As Double) 'Fuer extra Ausgabe
  Dim buf$
  Locate row, col
  buf$ = Space$(45) '40 Zeichen lang
  Mid$(buf$, 1) = label$
  Print Using buf$ + ": ###,###,###,###.##"; number
End Sub


Function getNumber# (row, col, prompt25$) 'Laenge der Ausgabe steuern
  Dim K$, num$
  Locate row, col: Print prompt25$; "? "
  K$ = InKey$
  While K$ <> Chr$(13)
    If Len(K$) Then
      'Fuer Nachkommastelle muss "." gedrueckt werden
      If InStr("-0123456789.", K$) Then
        num$ = num$ + K$
        EinPlatz row, col, prompt25$, Val(num$)
      ElseIf Asc(K$) = 8 Then
        If Len(num$) Then
          num$ = Left$(num$, Len(num$) - 1)
          EinPlatz row, col, prompt25$, Val(num$)
        End If
      End If
    End If
    K$ = InKey$
  Wend
  getNumber# = Val(num$)
End Function

Screen _NewImage(800, 672, 32)      ' 672 give you 42 rows so 2 extra rows to avoid scrolling.


[Image: image-2022-06-12-191621191.png]
b = b + ...
Reply
#38
Thanks, now it works. I set it to 682.
I've now noticed a mistake in reasoning:  Manufacturing costs ("Herstellkosten") result from material costs and production wages I+II (Fertigungslöhne I+II); nothing needs to be entered.

A small rounding error(?) can be seen in the screenshot. It should actually be 558,125.12. This is probably due to the different treatment of rounding in Basic and the C++ compiler.


Code: (Select All)
'Herstellkosten = Materialkosten + Fertigungskosten I + II
Herstellkosten = (fertMaterialkosten + fertFertigungskosten1) + fertFertigungskosten2
AusPlatz 22, 3, "Herstellkosten", Herstellkosten

[Image: Angebot-Rundungsfehler-HP202.jpg]
Reply
#39
Rounding errors are notorious in QB64, for currency do what Steve suggests use Long integers and then use a showCurrency routine that inserts the decimal point 3 spaces to left when ever need to display a number. I did this with my adding machine and haven't had any annoying errors since.
b = b + ...
Reply
#40
(06-13-2022, 07:07 PM)bplus Wrote: Rounding errors are notorious in QB64, for currency do what Steve suggests use Long integers and then use a showCurrency routine that inserts the decimal point 3 spaces to left when ever need to display a number. I did this with my adding machine and haven't had any annoying errors since.

Kind of reminds me of Cobol.   Tongue

Pic, Pic, Pic, . . . (Microfocus Cobol 3.0 Prof)
Code: (Select All)
WORKING-STORAGE SECTION.
. . .
77  Menge          PIC 9(3).
       77  Artikel        PIC X(20).
       77  Einzelpreis    PIC 9(4)v99.
       77  Ges-Preis      PIC 9(5)v99.
       77  MwSt           PIC 99 VALUE 14.
       77  Endpreis       PIC 9(5)v99.
       77  A-Menge        PIC z9.
       77  A-Einzelpreis  PIC z.zz9,99.
       77  A-GesPreis     PIC zz.zz9,99.
       77  A-Endpreis     PIC zz.zz9,99.
       77  Endstrich      PIC X(80) VALUE ALL "-".
Reply




Users browsing this thread: 1 Guest(s)