I am playing around with setting up a class to process block of (string) data. Just a test
I would like to have a property (called TheMass) to return a number ie the mass ! which is extracted from a line of data (a string)
I set up a class (Module) as follows
and in "standard" module
I want to pass the variable call thestring to the property TheMass() which should extract the desired number from the supplied line
This not working (not too surprised as this is my 1st foray in Class). This is just a test as I want to set up other properties on the same concept (pass a block of data to extract specific numbers)
What is wrong with the code?
Thanks
I would like to have a property (called TheMass) to return a number ie the mass ! which is extracted from a line of data (a string)
I set up a class (Module) as follows
VBA Code:
Dim pthemass As Double
Public Property Get TheMass() As Double
TheMass = pthemass
End Property
Public Property Let TheMass(theline As String)
Dim linedata() As String
linedata() = Split(theline, "=")
pthemass = CDbl(linedata(1))
End Property
and in "standard" module
VBA Code:
Sub TestDataBlockClass()
Dim TheDataBlock As TheDataBlock
Set TheDataBlock = New TheDataBlock
thestring = "MASS = 999"
TheDataBlock.TheMass = thestring
Debug.Print "3: " & TheDataBlock.TheMass
End Sub
I want to pass the variable call thestring to the property TheMass() which should extract the desired number from the supplied line
This not working (not too surprised as this is my 1st foray in Class). This is just a test as I want to set up other properties on the same concept (pass a block of data to extract specific numbers)
What is wrong with the code?
Thanks