G
Guest
I'm going a little crazy trying to learn how to use arrays as properties in
VBScript classes. Hopefully someone can help. First, I can't figure out
whether it's possible to iterate through the members of an array that I have
assigned to a propety. Second, I'm finding the question of "Property Let"
versus "Property Set" to be very confusing.
I have this code that utilizes a custom class I've defined, called clsGroup:
myString = "(e-mail address removed), (e-mail address removed),
(e-mail address removed)"
Dim objGroup
Set objGroup = New clsGroup
objGroup.EmailsAsArray = ParseCommaDelimitedStringToArray(myString)
If I test the resulting array, as follows:
Response.Write(IsArray(objGroup.EmailsAsArray))
....it resolves to "True". So objGroup.EmailsAsArray is successfully assigned
an array, which is what I want.
Confusing things:
1) If I try a simple loop, as follows...
dim myThingy
For each myThingy in objGroup.EmailsAsArray
response.write myThingy & "<br>"
Next
....this doesn't work. It complains that I'm not dealing with a collection.
This makes some sense, because I have a collection wrapped up in an object.
What's the right practice and/or syntax in this case?
2) The second thing that has me confused is whether an array is an object or
not. I'm thinking it is not. I wasted a lot of time trying to use the
"Property Set" declaration in trying to assign the array to my
..EmailsAsArray property. In the end, the only thing that would not return an
error was the more typical "Get/Let" pair:
Public Property Get EmailsAsArray()
EmailsAsArray = m_objEmailsAsArray
End Property
Public Property Let EmailsAsArray(objEmailsAsArray)
m_objEmailsAsArray = objEmailsAsArray
End Property
The amount of literature devoted to Class development in classic ASP is
unimpressive. Maybe time to move on up to ASP.NET.
Any help out there?
-KF
VBScript classes. Hopefully someone can help. First, I can't figure out
whether it's possible to iterate through the members of an array that I have
assigned to a propety. Second, I'm finding the question of "Property Let"
versus "Property Set" to be very confusing.
I have this code that utilizes a custom class I've defined, called clsGroup:
myString = "(e-mail address removed), (e-mail address removed),
(e-mail address removed)"
Dim objGroup
Set objGroup = New clsGroup
objGroup.EmailsAsArray = ParseCommaDelimitedStringToArray(myString)
If I test the resulting array, as follows:
Response.Write(IsArray(objGroup.EmailsAsArray))
....it resolves to "True". So objGroup.EmailsAsArray is successfully assigned
an array, which is what I want.
Confusing things:
1) If I try a simple loop, as follows...
dim myThingy
For each myThingy in objGroup.EmailsAsArray
response.write myThingy & "<br>"
Next
....this doesn't work. It complains that I'm not dealing with a collection.
This makes some sense, because I have a collection wrapped up in an object.
What's the right practice and/or syntax in this case?
2) The second thing that has me confused is whether an array is an object or
not. I'm thinking it is not. I wasted a lot of time trying to use the
"Property Set" declaration in trying to assign the array to my
..EmailsAsArray property. In the end, the only thing that would not return an
error was the more typical "Get/Let" pair:
Public Property Get EmailsAsArray()
EmailsAsArray = m_objEmailsAsArray
End Property
Public Property Let EmailsAsArray(objEmailsAsArray)
m_objEmailsAsArray = objEmailsAsArray
End Property
The amount of literature devoted to Class development in classic ASP is
unimpressive. Maybe time to move on up to ASP.NET.
Any help out there?
-KF