Link to home
Start Free TrialLog in
Avatar of Ryan Bayne
Ryan BayneFlag for United Kingdom of Great Britain and Northern Ireland

asked on

List Boxes, Moving Items (Removing Then Adding)

I'm sure you will know what this code does...

Private Sub cmdP1BuyHood_Click()

Dim I As Integer
If lstBank.ListIndex = -1 Then Exit Sub
For I = lstBank.ListCount - 1 To 0 Step -1
If lstBank.Selected(I) = True Then
PropertyListP1.AddItem PropertyListP1.List(I)
lstBank.RemoveItem I
End If
Next I

End Sub

Well its for a monopoly game. I have 3 list boxes. The code above removes an item from the Bank list box and adds it to player 1's list box. Its not exactly what I need. I need to select 1 of 24 items in the list box and then click the command button however this obviously gives the user the choice of property. I only want them to be able to purchase the property they have
landed on.

So when the BUY button is pressed they buy the current property which is also displayed on a picture box using text boxes and
labels. I cant get my head around how I go about doing this but what I'm thinking is pressing the BUY button, checking the 'Title' of the property in the label and using this to add this property's item to the players list of bought property and removing it from the banks list. Is this possible and how would I do it?

So I have a command button, a list box holiding the property, a list box holding the players bought property at first empty, a picture box holding a label and text boxes with 1 label which holds the propertys name that is currently occupied.
ASKER CERTIFIED SOLUTION
Avatar of dr_binks
dr_binks

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dr_binks
dr_binks

heh, I just noticed the mistake I made, cheers :)
Avatar of Ryan Bayne

ASKER

Let me confirm. This code checks the label and enables its sell. It doesnt allow the list box to be clicked on.
Would it be simple to enable selection however not allow the purchase of anything apart from the property that is also
displayed in label that allready displays the property name? Basically, check the label to see what text it holds and check to see if there is an item in the list with that name. If so THEN enable sale. If not no sale however when the player clicks on an item in the list I plan to pop up a new window with a title deed.

Thanks for the help so far.
i also agree with u modulo.... dr_binks  should be getting the points not me...


regards

rajesh
Thanks Modula :)