Need to find position of element in array list using

Posted on 2014-08-01
Last Modified: 2014-08-02
Hi I have an ArrayList in 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)
Question by:charlesbaldo
    LVL 23

    Accepted Solution

    Dim x As Integer = lstHoverText.IndexOf("Green")
    LVL 23

    Expert Comment

    by:Jens Fiederer
    (x is the index, with a value of 2)
    LVL 43

    Assisted Solution

    >>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

    Author Closing Comment

    Thank You

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now