Declaring Functions AS TYPEs
#12
(08-16-2023, 02:26 AM)TerryRitchie Wrote: So many times I have wished for this:

TYPE TYPE_VECTOR
    x AS SINGLE
    y AS SINGLE
END TYPE
. . .
Let's see if I understood your problem correctly. In the present program I should have created a "user-defined data type" (UDT). . . or?

Code: (Select All)
'Beispiel fuer eigene Datentypen (UDT) - 16. Aug. 2023

$Console:Only

Option _Explicit

Dim As Double Endpreis

'Definition der Datenstruktur - Direktzugriff
Type Motorrad
  Modell As String * 30
  Hubraum As String * 10
  Kilowatt As String * 15
  Preis As Double
End Type

Type Hersteller
  Firma As Motorrad
  Herstellername As String * 20
  Mehrwertsteuer As Double
End Type

Dim Motorradmodell As Hersteller

Input "Motorradmodell   : ", Motorradmodell.Firma.Modell
Input "Hubraum(ccm)     : ", Motorradmodell.Firma.Hubraum
Input "Leistung(KW)     : ", Motorradmodell.Firma.Kilowatt
Input "Preis            : ", Motorradmodell.Firma.Preis
Input "Mehrwertsteuer(%): ", Motorradmodell.Mehrwertsteuer
'Mehrwertsteuer is VAT (Valued Added Tax)

Print
Print "Modell          : ", Motorradmodell.Firma.Modell
Print "Hubraum         : ", Motorradmodell.Firma.Hubraum
Print "Leistung(KW)    : ", Motorradmodell.Firma.Kilowatt
Print Using "Preis ohne MWS   : ####.## Euro"; Motorradmodell.Firma.Preis

Endpreis = ((Motorradmodell.Firma.Preis / 100) * Motorradmodell.Mehrwertsteuer) + Motorradmodell.Firma.Preis
Print Using "Endpreis mit MWS : ####.## Euro"; Endpreis

End
I noticed a strange behavior during the output, see screenshot. Is this now an bug, or what is the reason?

[Image: Ausgabe-eigenartig.jpg]
Reply


Messages In This Thread
Declaring Functions AS TYPEs - by TerryRitchie - 08-16-2023, 02:26 AM
RE: Declaring Functions AS TYPEs - by dbox - 08-16-2023, 02:56 AM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 03:08 AM
RE: Declaring Functions AS TYPEs - by OldMoses - 08-16-2023, 11:53 AM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 12:33 PM
RE: Declaring Functions AS TYPEs - by a740g - 08-16-2023, 12:38 PM
RE: Declaring Functions AS TYPEs - by bplus - 08-16-2023, 02:38 PM
RE: Declaring Functions AS TYPEs - by Kernelpanic - 08-16-2023, 04:14 PM
RE: Declaring Functions AS TYPEs - by grymmjack - 08-16-2023, 09:50 PM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 11:25 PM
RE: Declaring Functions AS TYPEs - by bplus - 08-17-2023, 12:41 AM



Users browsing this thread: 3 Guest(s)