473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

determine items in array

JT
how do i determine how many items are in an array? the following code
creates an array of values each time a space is found in a name field. the
problem is that sometimes names have middle initials and sometimes they do
not. so i want to determine how many items exist in this array created by
the split BEFORE assigning values:

name_of_customer = Split(customer_name," ", -1, 1)

first_name = name_of_customer(0)
middle_initial = name_of_customer(1)

thanks much

jt
Jul 19 '05 #1
5 1831
look at ubound and lbound
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"JT" <je******@sppinc.net> wrote in message
news:O%****************@TK2MSFTNGP09.phx.gbl...
how do i determine how many items are in an array? the following code
creates an array of values each time a space is found in a name field. the problem is that sometimes names have middle initials and sometimes they do
not. so i want to determine how many items exist in this array created by
the split BEFORE assigning values:

name_of_customer = Split(customer_name," ", -1, 1)

first_name = name_of_customer(0)
middle_initial = name_of_customer(1)

thanks much

jt

Jul 19 '05 #2
Arrays in VBScript are zero based and cannot be changed to base 1 (option
base 1) as they can in VB. So, knowing that and knowing the UBound
function, the number of items in an array is the ubound of the dimension +
1.

name_of_customer = Split(customer_name," ", -1, 1)
NumberOfItems = UBound(name_of_customer, 1) + 1

The ",1" is an optional argument for single dimensional arrays. The array
dimensions start at 1, not 0.

Ray at work

"JT" <je******@sppinc.net> wrote in message
news:O%****************@TK2MSFTNGP09.phx.gbl...
how do i determine how many items are in an array? the following code
creates an array of values each time a space is found in a name field. the problem is that sometimes names have middle initials and sometimes they do
not. so i want to determine how many items exist in this array created by
the split BEFORE assigning values:

name_of_customer = Split(customer_name," ", -1, 1)

first_name = name_of_customer(0)
middle_initial = name_of_customer(1)

thanks much

jt

Jul 19 '05 #3
p.s. A more universal way that would make it so you don't have to worry
about 1 or 0 based arrays would probably be to use the lbound and the ubound
as so:

iNumberOfItems = UBound(theArray, theDimension) - LBound(theArray,
theDimension) + 1

Ray at work
"JT" <je******@sppinc.net> wrote in message
news:O%****************@TK2MSFTNGP09.phx.gbl...
how do i determine how many items are in an array? the following code
creates an array of values each time a space is found in a name field. the problem is that sometimes names have middle initials and sometimes they do
not. so i want to determine how many items exist in this array created by
the split BEFORE assigning values:

name_of_customer = Split(customer_name," ", -1, 1)

first_name = name_of_customer(0)
middle_initial = name_of_customer(1)

thanks much

jt

Jul 19 '05 #4
JT wrote:
how do i determine how many items are in an array? the following code
creates an array of values each time a space is found in a name
field. the problem is that sometimes names have middle initials and
sometimes they do not. so i want to determine how many items exist
in this array created by the split BEFORE assigning values:

name_of_customer = Split(customer_name," ", -1, 1)

first_name = name_of_customer(0)
middle_initial = name_of_customer(1)

thanks much

jt

Use the Ubound function to determine the largest available index number for
the array. Since arrays are zero-based, add one to get the count of the
array's items:

elements = ubound(name_of_customer) + 1

HTH,
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #5
UBound(name_of_customer) + 1

Bob Lehmann

"JT" <je******@sppinc.net> wrote in message
news:O#**************@TK2MSFTNGP09.phx.gbl...
how do i determine how many items are in an array? the following code
creates an array of values each time a space is found in a name field. the problem is that sometimes names have middle initials and sometimes they do
not. so i want to determine how many items exist in this array created by
the split BEFORE assigning values:

name_of_customer = Split(customer_name," ", -1, 1)

first_name = name_of_customer(0)
middle_initial = name_of_customer(1)

thanks much

jt

Jul 19 '05 #6

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

Similar topics

2
by: Jason | last post by:
I have a number of arrays that are populated with database values. I need to determine which array has the highest ubound out of all the arrays. The array size will always change based on the...
0
by: tommazzo | last post by:
I'm currently writing a photo album sotware in C#. I'm using a ListView component to diaplay thumbnail previews of the photos and want to give the user the possibility to rearrange the photos via a...
14
by: Roman Mashak | last post by:
Hello, All! Is there an easy way to determine that array e.g. int X contains ordered items (for example, ascending), except running loop with comparison of items? It would be good to provide...
4
by: mb | last post by:
what is the best way to do this: In a game I want to a class called "Items". This class will have the game items public class Items { public int Chair public int Table . . .and so on . . .
21
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each...
0
by: Brian Henry | last post by:
Since no one else knew how to do this I sat here all morning experimenting with this and this is what I came up with... Its an example of how to get a list of items back from a virtual mode list...
8
by: No bother | last post by:
I have a table with two columns, one named master, the other slave. Each column has a set of numbers. A number in one column can appear in the other. I am trying to see if there is any infinite...
21
by: John Salerno | last post by:
If I want to make a list of four items, e.g. L = , and then figure out if a certain element precedes another element, what would be the best way to do that? Looking at the built-in list...
6
by: =?Utf-8?B?bWFnZWxsYW4=?= | last post by:
Hi, I'd appreciae any advice on how to do this in VB 2005. I have a simple array;e..g, a list of States, e.g., CA, WA, ID, AL, and etc... I like to determine how many unqiue "States" are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.