Results 1 to 2 of 2

Thread: Comparing a variable to an array

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98

    Comparing a variable to an array

    Alrighty, Say i have this array

    1
    5
    7
    10
    15


    Right? Can i compare the variable A = 7 to that array to see what position 7 is in the array?

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Yes!

    I believe you can do this:

    VB Code:
    1. Dim myArray() As Integer = {1, 5, 7, 10, 15}
    2. Dim intSearch as Integer = 7
    3. Debug.WriteLine(Array.IndexOf(myArray, intSearch))
    This world is not my home. I'm just passing through.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width