01-06-2023, 03:20 PM
(This post was last modified: 01-06-2023, 03:25 PM by Kernelpanic.)
(01-04-2023, 11:41 PM)TerryRitchie Wrote: https://www.qb64tutorial.com/lesson8
Everything you ever wanted to know about 1D, 2D, 3D, and 4D arrays, with examples.
Your example does not show a real three-dimensional array, but three two-dimensional ones. I don't know now how I for example, a three-dimensional array "Sales" should represent 12 months, 30 days, 52 weeks.
This is a real three-dimensional field:
Code: (Select All)
$Console:Only
Option Base 1
Dim As Integer dreiDimFeld(3, 5, 7)
Dim As Integer dm, dz, ds, dFeld
Dim As Integer ebene, zeile, spalte
Locate 2, 2
dFeld = 1
For dm = 1 To 3
For dz = 1 To 5
Locate CsrLin + 1, 2
For ds = 1 To 7
dreiDimFeld(dm, dz, ds) = dFeld
Print Using "### "; dreiDimFeld(dm, dz, ds),
dFeld = dFeld + 1
Next
Next
Print: Locate , 2
Next
Locate CsrLin + 2, 2
Input "Zeige Wert in Ebene : ", ebene
Locate CsrLin + 0, 2
Input "Zeige Wert in Zeile : ", zeile
Locate CsrLin + 0, 2
Input "Und in Spalte : ", spalte
Locate CsrLin + 1, 2
Print Using "Wert in Ebene: # Zeile: # Spalte: # ist: ###"; ebene, zeile, spalte, dreiDimFeld(ebene, zeile, spalte)
End
When displaying months, days, weeks, etc., one could do something like this; just an idea, not tested.
Code: (Select All)
$Console:Only
Option _Explicit
Dim As Integer ebene, zeile, spalte
Option Base 1
Type InternetHandel
monate As String * 15
tage As Integer
End Type
Dim Umsatz(1 To 30) As InternetHandel
PS: Something just went wrong: No access to the server.