Forum Home
Press F1
 
Thread ID: 93142 2008-09-05 01:56:00 Sorting a VB 2008 Array jwil1 (65) Press F1
Post ID Timestamp Content User
702608 2008-09-05 01:56:00 Hi all,

How does one sort a VB 2008 Structure array...

I have created this Structure...


Public Structure Customer

Dim strName As String
Dim strItem As String
Dim decAmount As Decimal

End Structure


I have then declared an array of type Customer.

So now there is an array (of type Customer) which contains three of type Customer.

Code...


Customer(0).strName = "Mr A B"
Customer(0).strItem = "22-Inch LCD Monitor"
Customer(0).decAmount = 350

...


Customer(2).strName = "Mr C D"
Customer(2).stritem = "Asus Laptop"
Customer(2).decAmount = 1499


I would like to use the Array.Sort function if possible.

How can I sort them by decAmount??
jwil1 (65)
702609 2008-09-05 02:25:00 Have your structure implement IComparable (based on comparing decAmount).
msdn.microsoft.com
dyewitness (9398)
1