Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Quick VB Question.

  • 27-04-2004 07:42PM
    #1
    Closed Accounts Posts: 1,637 ✭✭✭


    Hi,

    I have question on list boxes, im trying to have 2 list boxes one with values e.g. "Car", "Boat" etc.. & the other as a number e.g. 5

    When I click on either the number or the item I want the number in the number list box to go down by 1.

    Please have a look @ the image to get what I mean.

    Thanks in advance Joe.

    list.JPG


Comments

  • Closed Accounts Posts: 1,637 ✭✭✭joePC


    heres what I got so far:

    Private Sub List1_Click()

    Count = List2.Index

    If List2.List(Count) = 1 Then

    MsgBox "Item out of stock"

    End If

    If List2.List(Count) = 0 Then

    Exit Sub

    End If

    List2.List(Count) = List2.List(Count) - 1

    End Sub


  • Closed Accounts Posts: 1,637 ✭✭✭joePC


    OK get it sorted:

    [PHP]

    Private Sub List1_Click()

    DecrementStock List1.ListIndex

    End Sub

    Private Sub List2_Click()

    DecrementStock List2.ListIndex

    End Sub

    Public Sub DecrementStock(Count As Integer)

    If List2.List(Count) = 1 Then
    MsgBox "Item out of stock"

    End If
    If List2.List(Count) = 0 Then
    Exit Sub
    End If
    List2.List(Count) = List2.List(Count) - 1

    End Sub

    [/PHP]


Advertisement