Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,752 questions

55,516 answers

573 users

How to create and set values to a 3d array in VB.NET

1 Answer

0 votes
Imports System

Class Program
    Public Shared Sub InitializeArray(ByVal array As Integer(,,), ByVal x As Integer, ByVal y As Integer, ByVal z As Integer)
        For i As Integer = 0 To x - 1
            For j As Integer = 0 To y - 1
                For k As Integer = 0 To z - 1
                    array(i, j, k) = i + j + k
                Next
            Next
        Next
    End Sub

    Public Shared Sub PrintArray(ByVal array As Integer(,,), ByVal x As Integer, ByVal y As Integer, ByVal z As Integer)
        For i As Integer = 0 To x - 1
            For j As Integer = 0 To y - 1
                For k As Integer = 0 To z - 1
                    Console.Write(array(i, j, k) & " ")
                Next

                Console.WriteLine()
            Next
        Next
    End Sub

	Public Shared Sub Main()
        Dim x As Integer = 2, y As Integer = 3, z As Integer = 4
        Dim array As Integer(,,) = New Integer(x - 1, y - 1, z - 1) {}

        InitializeArray(array, x, y, z)
        PrintArray(array, x, y, z)
    End Sub
End Class


' run:
'
' 0 1 2 3 
' 1 2 3 4 
' 2 3 4 5 
' 1 2 3 4 
' 2 3 4 5 
' 3 4 5 6 
'

 



answered Apr 21, 2025 by avibootz
...