Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when inputting ASCII text from COM port
#9
Quote:@MichelleL - I will confess, I have never used a SUB or a FUNCTION . . .
Finally something for fun and play again.  Big Grin  Examples of sub and function. 
One can also pass a function as an argument to a sub. - You should stop using GoSub these days and replace it with S&F; QuickBasic was already able to do that from 2.0(?)

kaufpreis = Purchase price
mehrwertSteuer = VAT
Endpreis/Gesamtpreis = Final price (total price)

Code: (Select All)

'Beispiel fuer SUB und Funktionen - 23. Jan. 2024

Option _Explicit

Declare Function Endpreis(kaufpreis, mehrwertSteuer As Double) As Double
Declare Sub auchEndpreis(eingabe As Double)

Dim As Double kaufpreis, mehrwertSteuer

Locate 3, 3
Input "Kaufpreis: ", kaufpreis
Locate 4, 3
Input "Mehrwertsteuer: ", mehrwertSteuer

Locate 6, 3
Print Using "Der Endpreis betraegt: ####,#.## Euro"; Endpreis(kaufpreis, mehrwertSteuer)

Locate 8, 3
'Function as an argument to a sub
Call auchEndpreis(Endpreis(kaufpreis, mehrwertSteuer))

End

Sub auchEndpreis (eingabe As Double)

  Dim As Double subGesamtpreis

  subGesamtpreis = eingabe
  Print Using "Der Endpreis betraegt: ####,#.## Euro"; subGesamtpreis

End Sub

Function Endpreis (kaufpreis, mehrwertSteuer As Double)

  Dim As Double gesamtpreis

  gesamtpreis = kaufpreis + ((kaufpreis * mehrwertSteuer) / 100)
  Endpreis = gesamtpreis
End Function
Reply


Messages In This Thread
RE: Error when inputting ASCII text from COM port - by Kernelpanic - 01-23-2024, 09:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mac debugger not connecting, a user error! BlameTroi 0 110 02-07-2026, 06:18 PM
Last Post: BlameTroi
  ERROR MESSAGES COLORS ? aurel 5 399 01-02-2026, 11:26 AM
Last Post: aurel
  Using CONST & _RGB used together seem to error... Dav 12 714 12-12-2025, 12:29 AM
Last Post: Dav
  error doing image collision detection with _MemGet madscijr 55 4,769 10-01-2025, 03:25 PM
Last Post: bplus
  error on function returning _mem Herve 5 698 07-05-2025, 08:06 PM
Last Post: hsiangch_ong

Forum Jump:


Users browsing this thread: 1 Guest(s)