Hello
Is there a way to get the index of an item in an array? For instance,
if I have:
MyArray = Array("NY","CT" ,"TX","NM")
....can I see what position CT is in the array?
Thanks 4 7352
THe only way to get an index from an array is to loop through the array
until you match the desired value. YOu can use a collection object
which uses keys collObj.Add(val ue, key).
Rich
*** Sent via Developersdex http://www.developersdex.com ***
.... but even with a collection you can't find the index of an item without
looping through the collection.
--
Terry Kreft
"Rich P" <rp*****@aol.co mwrote in message
news:45******** *************** @news.qwest.net ...
THe only way to get an index from an array is to loop through the array
until you match the desired value. YOu can use a collection object
which uses keys collObj.Add(val ue, key).
Rich
*** Sent via Developersdex http://www.developersdex.com ***
mi********@gmai l.com wrote:
Hello
Is there a way to get the index of an item in an array? For instance,
if I have:
MyArray = Array("NY","CT" ,"TX","NM")
...can I see what position CT is in the array?
Thanks
If it were important I'd hack something up along these lines (it would
need some more work):
Dim MyArray As Variant
Dim tempString As String
MyArray = Array("NY", "CT", "TX", "NM")
tempString = "/" & Join(MyArray, "/") & "/"
Debug.Print UBound(Split(le ft(tempString, InStr(tempStrin g, "/CT/")),
"/")) - 1
but ... why would it be important?
On 14 Nov 2006 12:51:56 -0800, mi********@gmai l.com wrote:
How did you get these values into this variant array? Perhaps
something can be done at the source.
If not, just loop using a For Each loop. On small arrays like this the
ugly n/2 performance is negligible.
-Tom.
>Hello Is there a way to get the index of an item in an array? For instance, if I have:
MyArray = Array("NY","CT" ,"TX","NM")
...can I see what position CT is in the array? Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: lawrence |
last post by:
I wanted to test xml_parse_into_struct() so I took the example off of
www.php.net and put this code up on a site:
<?php
$simple = <<<END
<item>
|
by: Magnus Warker |
last post by:
Hi,
I want to traverse an (associative) array, starting from its current
position, until a certain element is reached. Then, in certain cases, I
want to be able to reset the current position of the array to the one that
we had before touching the array.
I. e., i need something like funcctions getpos and setpos:
----------
|
by: dam_fool_2003 |
last post by:
Hai,
For a notes in web is saw the following lines:
Accessing an item at an arbitrary position:
If the items in the
sequence are numbered 0, 1, ... and we know the address in
memory of the first item, then the address of the ith
item is
(address of first item) + i * (size of an item)
So I tried the following to see the address of the first item (ie 2):
|
by: melanieab |
last post by:
Hi,
I'm trying to store all of my data into one file (there're about 140 things
to keep track of). I have no problem reading a specific string from the
array file, but I wasn't sure how to replace just one item. I know I can get
the entire array, then save the whole thing (with a for loop and if
statements so that the changed data will be saved), but it seems like a lot
of unnecessary reading and writing. Is there a way to directly save...
|
by: Dan |
last post by:
I wonder if anyone has suggestions for reducing the amount of time it would take to search my array using the function that I have written. I want to find a position in the array of an item that matches on all three variables. Suggestions?
Public Shared Function GetArrayPosition(ByVal ipRemoteEndPoint As String, ByVal intEngine_Type As Integer, ByVal intEngine_ID As Integer)
For i As Integer = 0 To aryDevice.GetUpperBound(1)
If...
| |
by: Antoine |
last post by:
Herfried and Cor:-
I used tracing and actually tracked down the code that was causing the
problem most likely. I wonder if you wanted to comment on it.
Also I wonder if there is a better way of testing if there is data than
testing the length of the xml string I used as stringreader to create the
dataset, but thats a side issue.
I think I tried isdbnull and is nothing and stuff like that and they cause
|
by: Ant |
last post by:
Hi, I'm using an array list as the collection for my indexer (_alPeople).
When i try to set _alpeople to a value at a certain index, I get an error. I
can't simply add the value as it needs to be at an index set by the user.
the Set statement is this:
_people = value; or even _people.Insert(index,value);
but these throw 'ArgumentOutOfRange' exception stating: Must be non-negative
and less than the size of the collection.
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these in an
array. The application compiles but aborts without giving me any useful
information.
What I suspect is happening is infinite recursion. Each Directory
object creates an array of Subdirectories each of which has an array of...
|
by: BurnTard |
last post by:
I've been given the task to make a hangman like program, and it seemed simple to me, but I just can't make the code behave like I want it to. I need the code to check if the array "placement" is a session variable, and if not it needs to set up an array of equal length to the array "arr".
// Default.aspx.cs created with MonoDevelop
// User: Lynx at 14:08*02/16/2009
//
// To change standard headers go to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
| |