User-Defined Data Types

What we need is a variable that can hold multiple related values of the same or different type. You can create custom data types that are made up of multiple values using Structures. A Structure allows you to combine multiple values of the basic data types and handle them as a whole.


Structure structureName
Dim variable1 As varType
Dim variable2 As varType

Dim variablen As varType
End Structure


Public Class Form1

    Structure Person
        Dim age As Integer
        Dim dateOfBirth As Date
        Dim bankBalance As Single
        Dim name As String
    End Structure

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim john As Person ' declaring object to access person structure
        john.age = 35 ' accessing age of person

        Console.WriteLine(john.age) ' printing out

    End Sub
End Class