473,399 Members | 2,774 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,399 software developers and data experts.

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
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
Oct 16 '08 #1
1 1387
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.

"cmdolcet69" <co************@hotmail.comwrote in message
news:7a**********************************@u65g2000 hsc.googlegroups.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
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
Oct 17 '08 #2

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

Similar topics

2
by: Stephen | last post by:
I have an array list alSearchCriteria which contains values which vary each time its created. It will always have 15 items in the arraylist each time its created. Some of the values in the array...
2
by: CanoeGuy | last post by:
I have an array that I am populating from a database. I am looping through the array to write the values to a datagrid. At this point, I'm stuck. I can't figure out how to read the first four...
4
by: Paul M | last post by:
Larry, i've got an xml file which has multiple cities as the top level item. When i read it in using XMLReader, and define the variables, as below, it finds the correct number of cities in the...
6
by: Dan | last post by:
I'd like to loop through selected datagrid rows and extract specified columns from those rows. How would I do that? Thanks... Dan
4
by: Kelvin | last post by:
Dear All, Please help. Same as subject !!!
2
by: Stephen | last post by:
I have an array list alSearchCriteria which contains values which vary each time its created. It will always have 15 items in the arraylist each time its created. Some of the values in the array...
3
by: VB Programmer | last post by:
Here's the code: For Each li As ListItem In Me.lstAssignedEmailAddresses.Items If li.Selected = True Then Me.lstAssignedEmailAddresses.Items.Remove(li) End If Next When I remove an item I get...
2
by: Amjad | last post by:
I want to copy 1-D arrays to columns of a 2-D array. Is there a way of doing that without using a loop that will copy element by element?
17
by: Roshawn | last post by:
Hi, I have a small function that uses a For...Next loop. I am trying to place the results of the loop in a string array. My code is as follows: Dim i as Integer Dim str() as String For i =...
2
by: Paul73 | last post by:
First off...thank you all for this forum. I've lurked for quite a while and you've all been so helpful. It's a life saver for someone like me. Now here's my problem. What I'm trying to do is...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.