Looping and Arraylist

C

cmdolcet69

How can i get (gage) to represent gages 3 and 4 in my array list.....
I have a total of 6 points. 4 points are on COM1 and 2 points are on
COM2


Points 3 and 4 (which are on COM2) should populate
selectDualDSICOM2.Add(gage), however the array is populated with
points 1 and point 2.

Can anyone help?



For intloop = 0 To newGraphics.charLabelArrayList.Count - 1
If Not CType(newGraphics.charLabelArrayList(intloop),
Label).BackColor.Equals(Color.LightSteelBlue) And _
Not CType(newGraphics.readingLabelArrayList(intloop),
Label).BackColor.Equals(Color.Black) Then
If CType(listOfGagesInCurrentComponent(intloop),
PartfileLibrary.Gages).COMPort = 2 Then
selectDualDSICOM2.Clear()
selectDualDSICOM2.Add(gage)
If Not gage.Association = String.Empty Then
If
pFile.Gages(CStr(gage.Association).Substring(4) - 1).Characteristic =
CType(newGraphics.charLabelArrayList(intloop), Label).Text Then

selectDualDSICOM2.Add(pFile.Gages(intloop))
Exit For
End If
End If

End If
End If
Next
 
J

James Hahn

That's some of the horriblest code I've seen in a long time.

Get your values out into separate variables so you can look at them in the
debugger after the type conversions. Why are all those type conversions
needed? Get rid of them. Then you've got a chance of seeing which tests are
passing and failing and why it's getting to the assignment statements, and
what the values are when it gets there.

What on earth does
If Not CType(newGraphics.charLabelArrayList(intloop),
Label).BackColor.Equals(Color.LightSteelBlue)
mean?

Why isn't it the same as
If Not
newGraphics.charLabelArrayList(intloop).BackColor.Equals(Color.LightSteelBlue)

If it's not, then what are you expecting the Label.BackColor to be set to?

Using the background color of the label to determine whether or not the item
meets your criteria for this sort of processing suggests to me some very
poor design decisions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top