Results 1 to 4 of 4

Thread: Help with ListBox editing - [2002 / 2003]

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    1

    Help with ListBox editing - [2002 / 2003]

    Hey first time poster so be gentle >_<

    Writing an app that needs to read a value off a list box then update that value dynamically.

    so i figured write an add / subtract function for the first step

    Function increase(ByVal i As Integer, ByVal j As Integer) As Integer
    increase = i + j
    End Function

    Function decrease(ByVal i As Integer, ByVal j As Integer) As Integer
    decrease = i - j
    Function

    Then I get owned by being a novice when it comes to listboxes and arrays -- only being doing this for a couple of days now

    I tried

    Private Sub RemBal_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles RemBal.Click

    increase(CInt(Balance.SelectedIndex), CInt(TextBox1.Text))
    End Sub

    It Aims to read the value from highlighted part (the selected value)of a listBox called Balance then increase the value using the function above by a value that is put in a text box called TextBox1.

    Really just need help with selecting the value in a listbox and editing it

    Didn't really do much and was wondering if anyone could point me in the right direction. Thanks a bunch in advance
    Last edited by Currymunch14; Nov 11th, 2007 at 08:39 PM.

  2. #2
    Hyperactive Member Pac_741's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    298

    Re: Help with ListBox editing - [2002 / 2003]

    Currymunch14, i am not sure what you want to do can you explain me better ? if you dont want, no problem.
    C# and WPF developer
    My Website:
    http://singlebits.com/

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

    Re: Help with ListBox editing - [2002 / 2003]

    What does the SelectedIndex property of a ListBox represent? It represents the index of the item that is selected in the LstBox. Is that what you want? If the user selects the fifth item in the ListBox SelectedIndex will return 4, because indexes are zero-based. Now, if that item is the number 20, obviously you want 20, not 4. You get the item that is selected using the aptly-named SelectedItem property.
    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

  4. #4
    Hyperactive Member Pac_741's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    298

    Re: Help with ListBox editing - [2002 / 2003]

    I knew he had to use the Selected item property but i wasnt shure
    C# and WPF developer
    My Website:
    http://singlebits.com/

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