Looping and Arraylist

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cmdolcet69

    Looping and Arraylist

    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
    selectDualDSICO M2.Add(gage), however the array is populated with
    points 1 and point 2.

    Can anyone help?



    For intloop = 0 To newGraphics.cha rLabelArrayList .Count - 1
    If Not CType(newGraphi cs.charLabelArr ayList(intloop) ,
    Label).BackColo r.Equals(Color. LightSteelBlue) And _
    Not CType(newGraphi cs.readingLabel ArrayList(intlo op),
    Label).BackColo r.Equals(Color. Black) Then
    If CType(listOfGag esInCurrentComp onent(intloop),
    PartfileLibrary .Gages).COMPort = 2 Then
    selectDualDSICO M2.Clear()
    selectDualDSICO M2.Add(gage)
    If Not gage.Associatio n = String.Empty Then
    If
    pFile.Gages(CSt r(gage.Associat ion).Substring( 4) - 1).Characterist ic =
    CType(newGraphi cs.charLabelArr ayList(intloop) , Label).Text Then

    selectDualDSICO M2.Add(pFile.Ga ges(intloop))
    Exit For
    End If
    End If

    End If
    End If
    Next
  • James Hahn

    #2
    Re: Looping and Arraylist

    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(newGraphi cs.charLabelArr ayList(intloop) ,
    Label).BackColo r.Equals(Color. LightSteelBlue)
    mean?

    Why isn't it the same as
    If Not
    newGraphics.cha rLabelArrayList (intloop).BackC olor.Equals(Col or.LightSteelBl ue)

    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.

    "cmdolcet69 " <colin_dolcetti @hotmail.comwro te in message
    news:7a2aa52e-ec39-47b6-a448-46406849a779@u6 5g2000hsc.googl egroups.com...
    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
    selectDualDSICO M2.Add(gage), however the array is populated with
    points 1 and point 2.
    >
    Can anyone help?
    >
    >
    >
    For intloop = 0 To newGraphics.cha rLabelArrayList .Count - 1
    If Not CType(newGraphi cs.charLabelArr ayList(intloop) ,
    Label).BackColo r.Equals(Color. LightSteelBlue) And _
    Not CType(newGraphi cs.readingLabel ArrayList(intlo op),
    Label).BackColo r.Equals(Color. Black) Then
    If CType(listOfGag esInCurrentComp onent(intloop),
    PartfileLibrary .Gages).COMPort = 2 Then
    selectDualDSICO M2.Clear()
    selectDualDSICO M2.Add(gage)
    If Not gage.Associatio n = String.Empty Then
    If
    pFile.Gages(CSt r(gage.Associat ion).Substring( 4) - 1).Characterist ic =
    CType(newGraphi cs.charLabelArr ayList(intloop) , Label).Text Then
    >
    selectDualDSICO M2.Add(pFile.Ga ges(intloop))
    Exit For
    End If
    End If
    >
    End If
    End If
    Next

    Comment

    Working...