G
Greg
I’ve created the class below. It contains three properties (which I will be
referring to as fields). They are intProcessStep, strProcessCode and
strProcessDesc.
Public Class myProcess
Private m_strProcessCode As String
Private m_strProcessDesc As String
Private m_intProcessStep As Integer
Public Property strProcessCode() As String
Get
Return m_strProcessCode
End Get
Set(ByVal value As String)
m_strProcessCode = value
End Set
End Property
Public Property strProcessDesc() As String
Get
Return m_strProcessDesc
End Get
Set(ByVal value As String)
m_strProcessDesc = value
End Set
End Property
Public Property intProcessStep() As Integer
Get
Return m_intProcessStep
End Get
Set(ByVal value As Integer)
m_intProcessStep = value
End Set
End Property
End Class
Now, I can instantiate the class using the code below. This code snippet
allows me to store values in the class for a single record in this case.
Dim objProcess As New myProcess
objProcess.intProcessStep = 1
objProcess.strProcessCode = "New Code"
objProcess.strProcessDesc = "New Desc"
Now, this works fine for a single record. What I want to do though is define
objProcess as an array instead so that I can store more than a single record
in the class. I’d like to be able to assign values using something like
objProcess(0).intProcessStep, objProcess(1).intProcessStep,
objProcess(2).intProcessStep, etc, so that I may store one or more records in
the class. I tried the following. No error is initially reported, but when I
attempt to run the code, it stops.
Dim objProcess(2) As New myProcess
objProcess(0).intProcessStep = 1
objProcess(0).strProcessCode = "Code 1"
objProcess(0).strProcessDesc = "Desc 1"
objProcess(1).intProcessStep = 1
objProcess(1).strProcessCode = "Code 2"
objProcess(1).strProcessDesc = "Desc 2"
Is it possible to instantiate the myProcess class as an array or something
along this line as I’m suggesting?
Now, I’d like to pass this class to a function. The function will have no
prior knowledge of what the class contains, so it needs to be able to examine
the class to figure what properties (fields) it contains. And, when the field
is found, it needs to be able to read the data from that field. How could
this be done in the function when the class is passed?
Then, finally, assuming I can create the class as an array, how could I
determine the size of the array from the function it’s passed to so that I
can retrieve the data from each record.
referring to as fields). They are intProcessStep, strProcessCode and
strProcessDesc.
Public Class myProcess
Private m_strProcessCode As String
Private m_strProcessDesc As String
Private m_intProcessStep As Integer
Public Property strProcessCode() As String
Get
Return m_strProcessCode
End Get
Set(ByVal value As String)
m_strProcessCode = value
End Set
End Property
Public Property strProcessDesc() As String
Get
Return m_strProcessDesc
End Get
Set(ByVal value As String)
m_strProcessDesc = value
End Set
End Property
Public Property intProcessStep() As Integer
Get
Return m_intProcessStep
End Get
Set(ByVal value As Integer)
m_intProcessStep = value
End Set
End Property
End Class
Now, I can instantiate the class using the code below. This code snippet
allows me to store values in the class for a single record in this case.
Dim objProcess As New myProcess
objProcess.intProcessStep = 1
objProcess.strProcessCode = "New Code"
objProcess.strProcessDesc = "New Desc"
Now, this works fine for a single record. What I want to do though is define
objProcess as an array instead so that I can store more than a single record
in the class. I’d like to be able to assign values using something like
objProcess(0).intProcessStep, objProcess(1).intProcessStep,
objProcess(2).intProcessStep, etc, so that I may store one or more records in
the class. I tried the following. No error is initially reported, but when I
attempt to run the code, it stops.
Dim objProcess(2) As New myProcess
objProcess(0).intProcessStep = 1
objProcess(0).strProcessCode = "Code 1"
objProcess(0).strProcessDesc = "Desc 1"
objProcess(1).intProcessStep = 1
objProcess(1).strProcessCode = "Code 2"
objProcess(1).strProcessDesc = "Desc 2"
Is it possible to instantiate the myProcess class as an array or something
along this line as I’m suggesting?
Now, I’d like to pass this class to a function. The function will have no
prior knowledge of what the class contains, so it needs to be able to examine
the class to figure what properties (fields) it contains. And, when the field
is found, it needs to be able to read the data from that field. How could
this be done in the function when the class is passed?
Then, finally, assuming I can create the class as an array, how could I
determine the size of the array from the function it’s passed to so that I
can retrieve the data from each record.