473,574 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Classes: How do I iterate through a property that's an array?


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 = "Su***@u.washin gton.edu, Bo*@u.washingto n.edu,
Bi**@u.washingt on.edu"

Dim objGroup
Set objGroup = New clsGroup
objGroup.Emails AsArray = ParseCommaDelim itedStringToArr ay(myString)

If I test the resulting array, as follows:
Response.Write( IsArray(objGrou p.EmailsAsArray ))
....it resolves to "True". So objGroup.Emails AsArray 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.Emails AsArray
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_objEmailsAsAr ray
End Property
Public Property Let EmailsAsArray(o bjEmailsAsArray )
m_objEmailsAsAr ray = objEmailsAsArra y
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
Jul 22 '05 #1
1 6444
ke*****@u.washi ngton.edu wrote:
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 = "Su***@u.washin gton.edu, Bo*@u.washingto n.edu,
Bi**@u.washingt on.edu"

Dim objGroup
Set objGroup = New clsGroup
objGroup.Emails AsArray = ParseCommaDelim itedStringToArr ay(myString)
What is this "Parse..." thingy? Did you reinvent the builtin split() method?

If I test the resulting array, as follows:
Response.Write( IsArray(objGrou p.EmailsAsArray ))
...it resolves to "True". So objGroup.Emails AsArray 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.Emails AsArray
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?
Hmm, according to the docs, a "for each" loop should work with an array. In
fact, this works fine:

dim ar, i
ar=array(14,2,3 )
for each i in ar
response.write i & "<BR>"
next
Have you tried a simple "for i = 0 to ubound(...)" loop?


2) The second thing that has me confused is whether an array is an
object or not. I'm thinking it is not.


Correct. You never use Set with arrays in vbscript.

You can download the vbscript documentation from:
http://tinyurl.com/7rk6

Bob Barrows
PS. This isn't really an asp question: it's more of a vbscript question. The
vbscript gurus hang out at m.p.scripting.v bscript.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3942
by: ChronoFish | last post by:
Hi there, I want to iterate through an array starting at a known index. However the indexes are not linear. For example I have an array of events keyed by timestamp. $eventList = array (1064263264 => "event1", 10642635555 => "event2", 1064266666 => "event3", 1064267782 => "event4", 1064268812 => "event5"); I basically want to do a...
2
1442
by: BUX | last post by:
I have Function myFunction(myArgument) as string(myInteger) The line myFunction(myInteger) = myString give me an error. Also myFunction(myArgument)(myInteger) = myString give me an error.
7
2605
by: MP | last post by:
Hello, I am trying to write a class that will expose some properties. One of the property is extracted from a SQL database and can be NULL or some integer value. Is there a elegant way of implementing this in C# ? I do not want to use variant (or similar types) because I want to retain a strnong types property. Will I have no choices but...
2
1936
by: FOP | last post by:
Hi I'd like to know if a property can be a array of a structure in VB.NET I have a structure called sListItem and I need a property to be an array of that type, something like Public Property ListItems()(10) As sListItem ....that I'd call as
2
999
by: Prabhudhas Peter | last post by:
I need a property which acts as an array... -- Peter...
3
2950
by: andrepina | last post by:
I'm trying to write a simple program that receives two doubles and one array of char that can be of lenght 9 or 10, and then introduces this input into a class. How do I have to define the array of char in the main program, the class and when I call the class? Thanks Andre
8
1750
by: mast2as | last post by:
I almost apologize to ask this question but I have been starting at this code for a bit of time and don't understand what's wrong with it. I am not arguing about the fact it's good or not coding, it's actually a shorter version of something more complex that i am doing. Anway the idea is that there's a func Test which takes a pointer to...
4
1515
by: Zytan | last post by:
Classes should have private fields, and they should be accessed through properties. But what if the field is an array? I know you can use an indexer to use syntax on the entire class itself, but what about using the syntax for a property that hides a field that is an array? Is this possible? I was pretty sure it was in VB, but I must...
13
2391
by: Daniel Klein | last post by:
I have a class constructor that accepts an array as the only argument. The catch is that the array MUST be an 'integer-indexed' array, not an 'associative' array, because the index position has meaning. How can I test for this in the constructor without having to traverse the entire array and checking to make sure the keys are numeric and...
0
7801
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7808
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6450
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5616
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5299
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.