Closed Thread
Results 1 to 4 of 4

Thread: Using array index

  1. #1
    gaylo565's Avatar
    gaylo565 is offline Programming Professional
    Join Date
    May 2007
    Location
    flagstaff, az
    Posts
    268
    Rep Power
    21

    Using array index

    I have a question using a button array. I wanted to access a corresponding pic box while im looping through my button array...Is there a way to store the index to a variable to pass into the next method?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Using array index

    Set up the method with a parameter:

    Code:
    private void MyMethod(int index)
    {
      MessageBox.Show("The index is " + index.ToString());
    }
    As you can see, you can then access the variable within the method. To use the method:

    Code:
    MyMethod(6);
    - this uses the index 6 to pass to the method.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  4. #3
    textte is offline Newbie
    Join Date
    May 2008
    Posts
    2
    Rep Power
    0

    Re: Using array index

    or you can associate "commandtext" property with the index

  5. #4
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Using array index

    Yes, but that's not a very good way to do it. My way is a better way to pass parameters across the methods.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. using a variable as array index
    By jackson6612 in forum C and C++
    Replies: 4
    Last Post: 10-09-2011, 01:18 PM
  2. an array with char index
    By chipbu in forum C# Programming
    Replies: 2
    Last Post: 04-12-2010, 03:46 PM
  3. Array Index Out Of Bound
    By lovemarshall in forum Java Help
    Replies: 3
    Last Post: 03-08-2010, 12:15 PM
  4. Replies: 7
    Last Post: 01-24-2010, 10:02 PM
  5. remeber index after sorting an array
    By yellowzelo in forum Java Help
    Replies: 9
    Last Post: 12-19-2009, 09:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

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