Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Easy VBA question (Classes)?
If I've got a class variable with the following variables defined inside it as such:
dim pCount as integer
dim pResult as string
dim pNumbers(20) as byte
How do I write a "property get" routine to access individual pNumbers array items?
By that, I mean: I've been using:
Property Get Result() as string
Result = pResult
End Property
But for an Array, I'm having an issue. Failing this I'll cope with GETting the whole array.
Also, on that note, how do I do a LET for it too?
Many thanks
1 Answer
- RandyLv 41 decade agoFavorite Answer
Code:
Property Get Number(idx As Integer) As Byte
Number = pNumbers(idx)
End Property
Property Let Number(idx As Integer, bytNumber As Byte)
pNumbers(idx) = bytNumber
End Property
Use:
Sub test()
Dim MyClass As New HotClass ' your class name here
MyClass.Number(2) = 8
MsgBox MyClass.Number(2)
End Sub
Of course, you would want to do some data validation, etc.
Hope that helps...