Three-dimensional array
#15
(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. Big Grin

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.
Reply


Messages In This Thread
Three-dimensional array - by Kernelpanic - 01-03-2023, 06:39 PM
RE: Three-dimensional array - by bplus - 01-03-2023, 07:38 PM
RE: Three-dimensional array - by SpriggsySpriggs - 01-03-2023, 07:40 PM
RE: Three-dimensional array - by mnrvovrfc - 01-03-2023, 07:46 PM
RE: Three-dimensional array - by SMcNeill - 01-03-2023, 07:56 PM
RE: Three-dimensional array - by TempodiBasic - 01-03-2023, 11:13 PM
RE: Three-dimensional array - by Kernelpanic - 01-03-2023, 08:36 PM
RE: Three-dimensional array - by TempodiBasic - 01-03-2023, 11:07 PM
RE: Three-dimensional array - by Kernelpanic - 01-04-2023, 10:12 PM
RE: Three-dimensional array - by SMcNeill - 01-04-2023, 10:57 PM
RE: Three-dimensional array - by TerryRitchie - 01-04-2023, 11:41 PM
RE: Three-dimensional array - by Kernelpanic - 01-06-2023, 03:20 PM
RE: Three-dimensional array - by TempodiBasic - 01-05-2023, 09:07 PM
RE: Three-dimensional array - by mnrvovrfc - 01-05-2023, 10:07 PM
RE: Three-dimensional array - by TerryRitchie - 01-05-2023, 10:04 PM
RE: Three-dimensional array - by SpriggsySpriggs - 01-06-2023, 03:48 PM
RE: Three-dimensional array - by SMcNeill - 01-07-2023, 12:17 AM
RE: Three-dimensional array - by James D Jarvis - 01-07-2023, 04:53 AM
RE: Three-dimensional array - by mnrvovrfc - 01-07-2023, 06:41 AM
RE: Three-dimensional array - by TempodiBasic - 01-07-2023, 11:55 AM
RE: Three-dimensional array - by TempodiBasic - 01-08-2023, 05:39 PM



Users browsing this thread: 8 Guest(s)