Array Comparisons in Program

  • Thread starter Thread starter cmdolcet69
  • Start date Start date
C

cmdolcet69

Currently i write to an arraylist of (n) lenght. After I collect that
arraylist i have always been dumping the arraylist to a file (excel
spread). This time however i have been asked to create up to 4
arrayslist hold there value and compare all 4 array so that they have
unique values.

Example logic is below:
if my first array holds all unique values then i end
array1(5,6,7,8,9)

if my first array doesn't hold unique value i go another round and get
array2 then compare.
array1(3,4,5,5,6,7)
array2(2,7,7,8,9,1)
i would then take array1 and array2 and average them out to get
another avgarrylist that would hold unique values.


Can someon please help. How can i do this?
 
You could use a hashtable - if you add duplicates into a hashtable you'll
get an exception.


Can i do it with jsut comparing the arrays, i need the simplest and
quickest way of doing this.
i read somthing about an arraylist.sort? How would that work? I want
sort through my original arraylist and see if any duplicte are in the
arraylist.
 
Can i do it with jsut comparing the arrays, i need the simplest and
quickest way of doing this.

Using a hash table is the simplest.
i read somthing about an arraylist.sort? How would that work? I want
sort through my original arraylist and see if any duplicte are in the
arraylist.

You'll have to compare each element in the list?
 
Hi,

Assuming that you have version 2005.

Create a generic list instead of an arraylist, that you can do as well in
version 2003, however than you need some casting.

Cor
 
Hi,

Assuming that you have version 2005.

Create a generic list instead of an arraylist, that you can do as well in
version 2003, however than you need some casting.

Cor

"cmdolcet69" <[email protected]> schreef in bericht






- Show quoted text -

Im using vb.net 2003
below is how i create my arraylist from a partfile
Private Sub CreateControls()
'controls to put on the screen
Dim lblCharacteristic As Label
Dim lblName As Label
Dim lblReading As Label

Dim intLoop As Integer
Dim intReadingSize As Integer
Try
_charLabelArrayList = New ArrayList
_readingLabelArrayList = New ArrayList


For intLoop = 0 To _partfile.gageList.Count - 1
lblCharacteristic = New Label
lblName = New Label
lblReading = New Label

With lblReading
.Font = New System.Drawing.Font("Times New Roman",
8, FontStyle.Regular)
.BackColor = System.Drawing.Color.White
.ForeColor = System.Drawing.Color.Black
.AutoSize = True
.BorderStyle = BorderStyle.FixedSingle
.Text = "-00.00"
intReadingSize = .Width
.AutoSize = False
.Text = ""
.Width = intReadingSize
.TextAlign = HorizontalAlignment.Center
.TabIndex = intLoop
.BringToFront()
.CausesValidation = True
'AddHandler .Click, AddressOf ReadingLabel_Click
End With
_charLabelArrayList.Add(lblCharacteristic)
_readingLabelArrayList.Add(lblReading)

Next

What happens is that i have my readings on a timer and cast it to a
textbox.
CType(_readingLabelArrayList(intarrayindex), Label).Text =
gmux.MuxAnalogValues(1)


What I need to do is sort that _readingLabelArrayList so that i can
see if it hold all nique value i will then write the arraylist and
stop if not i will run the program again.
 
cmdolcett,

Make a simple class

Class MyOwnClass
Private Pietje as string
Private Jantje as string
End Class


Now you can do

Dim myOwnObject as MyOwnClass
Dim ar as new arraylist
ar.add(myOwnObject)
DirectCast(ar(0) , MyOwnClass).Pietje = "etc"
etc
 
Back
Top