Welcome to Dream.In.Code
Become a VB Expert!

Join 137,261 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,542 people online right now. Registration is fast and FREE... Join Now!




ListBox Control...

 
Reply to this topicStart new topic

ListBox Control...

babbles
29 Nov, 2006 - 09:56 PM
Post #1

New D.I.C Head
*

Joined: 28 Nov, 2006
Posts: 12


My Contributions
Hey..can you please help me with my problem...I have one list box . the list box contains Product Name, Quantity, Price and for the SubTotal and there is one textbox for the overall total...My problem is if I removed one item from the list the overall total is not decreasing.. Can you please help me????please...Super thanks...
User is offlineProfile CardPM
+Quote Post

eXceed69
RE: ListBox Control...
30 Nov, 2006 - 02:44 AM
Post #2

"Super Sentai Knight Of DawN"
Group Icon

Joined: 12 Nov, 2006
Posts: 682



Thanked: 1 times
Dream Kudos: 675
My Contributions
Please sir post your code, FORUM RULES we are eager to help you out...
User is offlineProfile CardPM
+Quote Post

babbles
RE: ListBox Control...
30 Nov, 2006 - 03:10 AM
Post #3

New D.I.C Head
*

Joined: 28 Nov, 2006
Posts: 12


My Contributions
QUOTE(eXceed69 @ 30 Nov, 2006 - 03:44 AM) *

Please sir post your code, FORUM RULES we are eager to help you out...

CODE

Private Sub cmdRemove_Click()

List1.RemoveItem List1.ListIndex

End Sub

How can I decrease the overall total if I remove one item in the list

User is offlineProfile CardPM
+Quote Post

Jayman
RE: ListBox Control...
30 Nov, 2006 - 07:42 AM
Post #4

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,985



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
You need to recalculate the total each time you add or remove an item from the list.
User is offlineProfile CardPM
+Quote Post

babbles
RE: ListBox Control...
1 Dec, 2006 - 07:00 AM
Post #5

New D.I.C Head
*

Joined: 28 Nov, 2006
Posts: 12


My Contributions
QUOTE(babbles @ 30 Nov, 2006 - 04:10 AM) *

QUOTE(eXceed69 @ 30 Nov, 2006 - 03:44 AM) *

Please sir post your code, FORUM RULES we are eager to help you out...

CODE

Private Sub cmdRemove_Click(
List1.RemoveItem List1.ListIndex

End Sub

How can I decrease the overall total if I remove one item in the list


how can I recalculate the total? Im sa confused about the indexedlist.

User is offlineProfile CardPM
+Quote Post

KeyWiz
RE: ListBox Control...
1 Dec, 2006 - 10:21 PM
Post #6

D.I.C Regular
Group Icon

Joined: 26 Oct, 2006
Posts: 428


Dream Kudos: 125
My Contributions
When you create a List it is very similar to creating an Array, the Difference is a List allows you to see the elements in your array.
As you add items to the list each item is given an INDEX VALUE which tells us where the computer is looking in the List.

The First Item loaded to an Array or a List has an INDEX VALUE of 0, the second one has an INDEX of 1 and so on.

When You Click on an Item in the List you can retrieve the VALUE of the INDEX

myVariable = List1.ListIndex

You can then use myVariable to Remove that exact item from the list.

You can then count through the remaining items and recalculate your total.

When an Item is removed from the list, all values above that point are reduced, leaving you with a list of consecutive INDEXes, ie if you had 5 items and remove #2, the List would now have indexes of 0,1,2,3

You can retrieve the number of items in a list with

myListItems = List1.ListCount

This will always be 1 number higher than the last elements' INDEX Value.

In a List of 6 Items myListItems will = 6 but the highest INDEX is 5, the LOWEST INDEX is 0


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 06:56PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month