473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do I delete and Item from and array

Hi can anyone help?

I'm making a shopping cart and am stuck on removing an item from my array?

The array is made :

cArray(ITEM_NAME,cItem) = ProductName

cArray(ITEM_PRODUCTID,cItem) = ProductID

cArray(ITEM_SIZE,cItem) = Size

cArray(ITEM_PRICE,cItem) = ProductPrice

cArray(ITEM_QUANTITY,cItem) = Qty

Then the cart is added to a session.

My question is how do i remove an item from the middle of this array?

Any help at all would be much appreciated

Thanks

Mike

Nov 17 '05 #1
7 1874
Removing an item from an array is not particularly easy, as you must make a
new array. You would probably be better off using a Collection than an
array. If you want to use an array, you would create a second array with a
length 1 less than the original, and assign each item that you don't want to
remove to the second array in a loop.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:KU*************@news-binary.blueyonder.co.uk...
Hi can anyone help?

I'm making a shopping cart and am stuck on removing an item from my array?

The array is made :

cArray(ITEM_NAME,cItem) = ProductName

cArray(ITEM_PRODUCTID,cItem) = ProductID

cArray(ITEM_SIZE,cItem) = Size

cArray(ITEM_PRICE,cItem) = ProductPrice

cArray(ITEM_QUANTITY,cItem) = Qty

Then the cart is added to a session.

My question is how do i remove an item from the middle of this array?

Any help at all would be much appreciated

Thanks

Mike

Nov 17 '05 #2
Thanks Kevin,
looking into a way of doing it with collections now.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oo**************@tk2msftngp13.phx.gbl...
Removing an item from an array is not particularly easy, as you must make a new array. You would probably be better off using a Collection than an
array. If you want to use an array, you would create a second array with a
length 1 less than the original, and assign each item that you don't want to remove to the second array in a loop.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:KU*************@news-binary.blueyonder.co.uk...
Hi can anyone help?

I'm making a shopping cart and am stuck on removing an item from my array?
The array is made :

cArray(ITEM_NAME,cItem) = ProductName

cArray(ITEM_PRODUCTID,cItem) = ProductID

cArray(ITEM_SIZE,cItem) = Size

cArray(ITEM_PRICE,cItem) = ProductPrice

cArray(ITEM_QUANTITY,cItem) = Qty

Then the cart is added to a session.

My question is how do i remove an item from the middle of this array?

Any help at all would be much appreciated

Thanks

Mike


Nov 17 '05 #3
Well for collections there is an excellent tutorial on that. Just visit any
catholic church on Sunday and watch how they do it. Amazing.
"Marc Bishop" <no******************@hotmail.com> wrote in message
news:G4************@news-binary.blueyonder.co.uk...
Thanks Kevin,
looking into a way of doing it with collections now.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oo**************@tk2msftngp13.phx.gbl...
Removing an item from an array is not particularly easy, as you must make
a
new array. You would probably be better off using a Collection than an
array. If you want to use an array, you would create a second array with a length 1 less than the original, and assign each item that you don't
want to
remove to the second array in a loop.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:KU*************@news-binary.blueyonder.co.uk...
Hi can anyone help?

I'm making a shopping cart and am stuck on removing an item from my

array?
The array is made :

cArray(ITEM_NAME,cItem) = ProductName

cArray(ITEM_PRODUCTID,cItem) = ProductID

cArray(ITEM_SIZE,cItem) = Size

cArray(ITEM_PRICE,cItem) = ProductPrice

cArray(ITEM_QUANTITY,cItem) = Qty

Then the cart is added to a session.

My question is how do i remove an item from the middle of this array?

Any help at all would be much appreciated

Thanks

Mike



Nov 17 '05 #4
Is there anything you need information about regarding using a Collection?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:G4************@news-binary.blueyonder.co.uk...
Thanks Kevin,
looking into a way of doing it with collections now.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oo**************@tk2msftngp13.phx.gbl...
Removing an item from an array is not particularly easy, as you must make
a
new array. You would probably be better off using a Collection than an
array. If you want to use an array, you would create a second array with a length 1 less than the original, and assign each item that you don't
want to
remove to the second array in a loop.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:KU*************@news-binary.blueyonder.co.uk...
Hi can anyone help?

I'm making a shopping cart and am stuck on removing an item from my

array?
The array is made :

cArray(ITEM_NAME,cItem) = ProductName

cArray(ITEM_PRODUCTID,cItem) = ProductID

cArray(ITEM_SIZE,cItem) = Size

cArray(ITEM_PRICE,cItem) = ProductPrice

cArray(ITEM_QUANTITY,cItem) = Qty

Then the cart is added to a session.

My question is how do i remove an item from the middle of this array?

Any help at all would be much appreciated

Thanks

Mike



Nov 17 '05 #5
Actually that would be great what was on my mind was using a Listbox and
just make is visible = false - not a good idea i think you'd agree - i
couldn't find any information apart from ASP(vbscript) collection.

thanks :)
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Is there anything you need information about regarding using a Collection?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:G4************@news-binary.blueyonder.co.uk...
Thanks Kevin,
looking into a way of doing it with collections now.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oo**************@tk2msftngp13.phx.gbl...
Removing an item from an array is not particularly easy, as you must make
a
new array. You would probably be better off using a Collection than an
array. If you want to use an array, you would create a second array with
a length 1 less than the original, and assign each item that you don't

want
to
remove to the second array in a loop.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:KU*************@news-binary.blueyonder.co.uk...
> Hi can anyone help?
>
> I'm making a shopping cart and am stuck on removing an item from my

array?
>
> The array is made :
>
>
>
> cArray(ITEM_NAME,cItem) = ProductName
>
> cArray(ITEM_PRODUCTID,cItem) = ProductID
>
> cArray(ITEM_SIZE,cItem) = Size
>
> cArray(ITEM_PRICE,cItem) = ProductPrice
>
> cArray(ITEM_QUANTITY,cItem) = Qty
>
>
>
> Then the cart is added to a session.
>
> My question is how do i remove an item from the middle of this

array? >
>
>
> Any help at all would be much appreciated
>
>
>
> Thanks
>
> Mike
>
>
>



Nov 17 '05 #6
I'm kind of confused now, since a Collection, like an Array, is a data
storage device in memory, and a ListBox is a UI element. The Common Language
Runtime has lots of different Collections you can use, as well as having the
ability to create your own strongly-typed Collections. A Collection is
similr to an Array, but has the capability of having items added and removed
from it easily, without having to create a new Collection. Rather than, as
in your example, using a multi-dimensional Array, what you need to do is to
create a Class or Structure that holds all of the data associated with a
single item in the Shopping Cart. Once you have done that, you simply create
an instance of the Class or Structure and add it to the Collection, using
the Add() method of the Collection. To remove it from the Collection, you
use the Remove() method of the Collection.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:5r***********@news-binary.blueyonder.co.uk...
Actually that would be great what was on my mind was using a Listbox and
just make is visible = false - not a good idea i think you'd agree - i
couldn't find any information apart from ASP(vbscript) collection.

thanks :)
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Is there anything you need information about regarding using a Collection?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:G4************@news-binary.blueyonder.co.uk...
Thanks Kevin,
looking into a way of doing it with collections now.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oo**************@tk2msftngp13.phx.gbl...
> Removing an item from an array is not particularly easy, as you must

make
a
> new array. You would probably be better off using a Collection than an > array. If you want to use an array, you would create a second array

with
a
> length 1 less than the original, and assign each item that you don't

want
to
> remove to the second array in a loop.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> http://www.takempis.com
> Big Things are made up of
> Lots of Little Things.
>
> "Marc Bishop" <no******************@hotmail.com> wrote in message
> news:KU*************@news-binary.blueyonder.co.uk...
> > Hi can anyone help?
> >
> > I'm making a shopping cart and am stuck on removing an item from my array?
> >
> > The array is made :
> >
> >
> >
> > cArray(ITEM_NAME,cItem) = ProductName
> >
> > cArray(ITEM_PRODUCTID,cItem) = ProductID
> >
> > cArray(ITEM_SIZE,cItem) = Size
> >
> > cArray(ITEM_PRICE,cItem) = ProductPrice
> >
> > cArray(ITEM_QUANTITY,cItem) = Qty
> >
> >
> >
> > Then the cart is added to a session.
> >
> > My question is how do i remove an item from the middle of this

array? > >
> >
> >
> > Any help at all would be much appreciated
> >
> >
> >
> > Thanks
> >
> > Mike
> >
> >
> >
>
>



Nov 17 '05 #7
Sorry Kevin,
yes i understand now,
i think i'll pick this up tomorrow with a clear head :)

thanks for your help !

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I'm kind of confused now, since a Collection, like an Array, is a data
storage device in memory, and a ListBox is a UI element. The Common Language Runtime has lots of different Collections you can use, as well as having the ability to create your own strongly-typed Collections. A Collection is
similr to an Array, but has the capability of having items added and removed from it easily, without having to create a new Collection. Rather than, as
in your example, using a multi-dimensional Array, what you need to do is to create a Class or Structure that holds all of the data associated with a
single item in the Shopping Cart. Once you have done that, you simply create an instance of the Class or Structure and add it to the Collection, using
the Add() method of the Collection. To remove it from the Collection, you
use the Remove() method of the Collection.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:5r***********@news-binary.blueyonder.co.uk...
Actually that would be great what was on my mind was using a Listbox and
just make is visible = false - not a good idea i think you'd agree - i
couldn't find any information apart from ASP(vbscript) collection.

thanks :)
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Is there anything you need information about regarding using a Collection?
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Marc Bishop" <no******************@hotmail.com> wrote in message
news:G4************@news-binary.blueyonder.co.uk...
> Thanks Kevin,
> looking into a way of doing it with collections now.
>
>
> "Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
> news:Oo**************@tk2msftngp13.phx.gbl...
> > Removing an item from an array is not particularly easy, as you must make
> a
> > new array. You would probably be better off using a Collection than
an
> > array. If you want to use an array, you would create a second
array
with
a
> > length 1 less than the original, and assign each item that you

don't want
> to
> > remove to the second array in a loop.
> >
> > --
> > HTH,
> >
> > Kevin Spencer
> > Microsoft MVP
> > .Net Developer
> > http://www.takempis.com
> > Big Things are made up of
> > Lots of Little Things.
> >
> > "Marc Bishop" <no******************@hotmail.com> wrote in message
> > news:KU*************@news-binary.blueyonder.co.uk...
> > > Hi can anyone help?
> > >
> > > I'm making a shopping cart and am stuck on removing an item from

my > array?
> > >
> > > The array is made :
> > >
> > >
> > >
> > > cArray(ITEM_NAME,cItem) = ProductName
> > >
> > > cArray(ITEM_PRODUCTID,cItem) = ProductID
> > >
> > > cArray(ITEM_SIZE,cItem) = Size
> > >
> > > cArray(ITEM_PRICE,cItem) = ProductPrice
> > >
> > > cArray(ITEM_QUANTITY,cItem) = Qty
> > >
> > >
> > >
> > > Then the cart is added to a session.
> > >
> > > My question is how do i remove an item from the middle of this

array?
> > >
> > >
> > >
> > > Any help at all would be much appreciated
> > >
> > >
> > >
> > > Thanks
> > >
> > > Mike
> > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Colin Steadman | last post by:
I have a multi-dimensional array that I want to delete items from. To do this I display a form and the user clicks some tick boxes. Then on the delete page I check which tick boxes were...
1
by: HeroOfSpielburg | last post by:
I'm writing a memory manager and overloading the operators "::new" and "::delete" I know this isn't always the smartest thing to do, but regardless, I was wondering what sort of considerations I...
2
by: Stephen | last post by:
I am trying to delete a row in a datagrid on the onclick of a asp:ButtonColumn. The datagrid is created from the items in an arraylist so what im trying to do is remove the item from the array and...
18
by: Hugh | last post by:
Hi, Is there easy way to delete elements from a 2D array? Thanks for your tip. Hugh
10
by: | last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily complicated than the other languages I know. I feel this is because there aren't many good official resources out there to...
1
by: flash | last post by:
Need hlep to delete array only because all function is ok (inser, sort andsearch) #include <iostream.h> //functions prototype void Insert(int,int); void Delete(int,int); int...
12
by: yufufi | last post by:
Hello, How does delete know how much memory to deallocate from the given pointer? AFAIK this informations is put there by new. new puts the size of the allocated memory before the just before...
7
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI...
1
by: jmarcrum | last post by:
Hello all! i have a “monitor-type” program, where my program recognizes my defined "commands”, and executes the given command, or produces an error message that says “unrecognized command”. After...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.