Results 1 to 5 of 5

Thread: [2008] Aray Help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    31

    [2008] Aray Help

    Ok, so I have this system working, now I need to know this.

    If I had this

    Code:
    Dim Ary() As String = {"522", "462", "521", "461", "463", "581", "448", "586", "523", "468", "471"}
    And when someone type into a textbox and click a button, how do I make the number from the Textbox find the number in the string and return what id in the string it is, like so if I was using 522 in the ary I have shown, it would highlight the first text in a combo box. Any ideas? If you didnt understand I will try to explain again.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2008] Aray Help

    I'd have to look, but there might be an Array.IndexOf method that would get what you are looking for. List has it, and Array should, too.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    31

    Re: [2008] Aray Help

    Quote Originally Posted by Shaggy Hiker
    I'd have to look, but there might be an Array.IndexOf method that would get what you are looking for. List has it, and Array should, too.
    I tried this

    Code:
    BikesBox.SelectedItem = Ary.IndexOf(Ary, TextBox2.Text)
    But it didn't find the 522 entry in the array

  4. #4
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: [2008] Aray Help

    this should work
    Code:
    MsgBox(Array.IndexOf(Ary, TextBox1.Text))

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Aray Help

    Quote Originally Posted by JaTochNietDan
    I tried this

    Code:
    BikesBox.SelectedItem = Ary.IndexOf(Ary, TextBox2.Text)
    But it didn't find the 522 entry in the array
    Isn't it a bit of a worry that the method you're calling is named IndexOf yet the property you're setting is the SelectedItem. If you're getting an index then shouldn't you be setting the SelectedIndex?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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