In object-oriented programming we use classes.
Let say your class could looks like:
Public Class TDataStoreClass
Implements IDataStoreClass
Private f1 As String = String.Empty
Private f2 As Integer = 0
Public Sub New()
End Sub
Public Sub New(ByVal _f1 As String, ByVal _f2 As Integer)
f1 = _f1
f2 = _f2
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
Public Property Field1() As String Implements IDataStoreClass.Field1
Get
Return f1
End Get
Set(ByVal value As String)
f1 = value
End Set
End Property
Public Property Field2() As Integer Implements IDataStoreClass.Field2
Get
Return f2
End Get
Set(ByVal value As Integer)
f2 = value
End Set
End Property
End Class
As you see, the above class has 2 fields:
Field1
(stores string value) and
Field2
(stores integer value) and implements properties from
IDataStoreClass
interface:
Public Interface IDataStoreClass
Property Field1() As String
Property Field2() As Integer
End Interface
To use this class we need to declare it in a module:
Module ModDataStore
Public dsc As IDataStoreClass = Nothing
End Module
Next, you should initialize your class (see
New
procedure) in the form class, on
Button_Click
event you can set values using class properties:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dsc.Field1 = Me.TextBox1.Text
dsc.Field2 = Integer.Parse(Me.TextBox2.Text)
End Sub
Public Sub New()
InitializeComponent()
dsc = New TDataStoreClass()
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class
The above example is very simple.
Read more about:
List(of T)
[
^] to use it with array of your data.