?
Solved

List Boxes, Moving Items (Removing Then Adding)

Posted on 2005-03-24
8
Medium Priority
?
170 Views
Last Modified: 2012-03-15
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.
0
Comment
Question by:Ryan Bayne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 5

Accepted Solution

by:
dr_binks earned 1000 total points
ID: 13627477
you could just say (at the very start of you program)
<nameoflist>.enabled=false
e.g. list1.enabled = false

you can still add/del items and make them selected.
the user cant click on the list.

'when player lands on property
for 1=0 to list.listcount-1
 if label.caption = list.list(i) then
 list.selectitem(i)=true
 exit for
next

'delete from bank
for 1=0 to list.listcount-1
 if label.caption = list.list(i) then
 list.removeitem(i)
 exit for
next

I think this is what you wanted

hope it helps

~Binks


0
 
LVL 3

Assisted Solution

by:r_a_j_e_s_h
r_a_j_e_s_h earned 1000 total points
ID: 13628877
a small change in previous code,. that's it... i know that is a typing mistake.. anyhow iam posting that...
******************************************************************************************

you could just say (at the very start of you program)
<nameoflist>.enabled=false
e.g. list1.enabled = false

you can still add/del items and make them selected.
the user cant click on the list.

'when player lands on property
for i=0 to list.listcount-1
 if label.caption = list.list(i) then
 list.selectitem(i)=true
 exit for
next

'delete from bank
for i=0 to list.listcount-1
 if label.caption = list.list(i) then
 list.removeitem(i)
 exit for
next

I think this is what you wanted

hope it helps

~Binks
0
 
LVL 5

Expert Comment

by:dr_binks
ID: 13629786
heh, I just noticed the mistake I made, cheers :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:Ryan Bayne
ID: 13631433
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.
0
 
LVL 3

Expert Comment

by:r_a_j_e_s_h
ID: 13638205
i also agree with u modulo.... dr_binks  should be getting the points not me...


regards

rajesh
0
 
LVL 5

Expert Comment

by:dr_binks
ID: 13651348
Thanks Modula :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question