Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need to find position of element in array list using vb.net

Posted on 2014-08-01
4
Medium Priority
?
217 Views
Last Modified: 2014-08-02
Hi I have an ArrayList in VisiaulBasic.net 2012

 Private lstHoverText As New ArrayList

.....
.....
.....

lstHoverText .Add("Red")
lstHoverText .Add("Blue")
lstHoverText .Add("Green")
lstHoverText .Add("Yellow")

I need to know "Green" is position 3 (zero based)
0
Comment
Question by:Charles Baldo
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 1900 total points
ID: 40235396
Dim x As Integer = lstHoverText.IndexOf("Green")
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 40235398
(x is the index, with a value of 2)
0
 
LVL 45

Assisted Solution

by:AndyAinscow
AndyAinscow earned 100 total points
ID: 40235766
>>lstHoverText .Add("Red")
lstHoverText .Add("Blue")
lstHoverText .Add("Green")
lstHoverText .Add("Yellow")

I need to know "Green" is position 3 (zero based)


Green is position 2 using zero based maths in that example.  If you really want the number 3 then just add one to the method given to you already.  Dim x As Integer = lstHoverText.IndexOf("Green") + 1
0
 

Author Closing Comment

by:Charles Baldo
ID: 40236028
Thank You
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question