Arraylist Index Question

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

cmdolcet69

If need to know how to take all arraylist value and compare them in an
if statement.

if i have the following code:
if Ctype(newgraphics.readinglabelarralist(intloop),
label).test="4096.00" then

End if

Note that i do declare me intloop in a for intloop =0 to a
value.cout-1

However what i need it to say that all values in
readinglabelarraylist(all value), label.text ="4096.00"

How can i change the (intloop) to a (all values). I want to check that
if all values are "4096.00" then do somthing.
 
cmdolcet69 said:
If need to know how to take all arraylist value and compare them in
an if statement.

if i have the following code:
if Ctype(newgraphics.readinglabelarralist(intloop),
label).test="4096.00" then

End if

Note that i do declare me intloop in a for intloop =0 to a
value.cout-1

However what i need it to say that all values in
readinglabelarraylist(all value), label.text ="4096.00"

How can i change the (intloop) to a (all values). I want to check
that if all values are "4096.00" then do somthing.

Why do you want to change the loop? It's what you need. What does not work?

In VB 2008 you can do nice things like this:

dim b as boolean

b = Array.TrueForAll(labels, Function(l As Label) l.Text = "4096.00")

where 'labels' is an array of labels.

But, usually you should process the data itself, not the data that has been
converted to strings and is shown in labels.


Armin
 
Armin Zingler said:
In VB 2008 you can do nice things like this:

dim b as boolean

b = Array.TrueForAll(labels, Function(l As Label) l.Text =
"4096.00")

where 'labels' is an array of labels.

I know you have an arraylist. Was only an example. Doesn't change that you
need a loop.


Armin
 
If need to know how to take all arraylist value and compare them in an
if statement.

if i have the following code:
if Ctype(newgraphics.readinglabelarralist(intloop),
label).test="4096.00" then

End if

Note that i do declare me intloop in a for intloop =0 to a
value.cout-1

However what i need it to say that all values in
readinglabelarraylist(all value), label.text ="4096.00"

How can i change the (intloop) to a (all values). I want to check that
if all values are "4096.00" then do somthing.

First, I would recommend using a List(Of Label) rather than ArrayList.
That way you don't have to cast the contents.

dim isEqual as Boolean = True

With newgraphics
For intloop as Integer = 0 to .readinglabelarralist.count - 1
If CType(.readinglabelarralist(intloop), Label).Text <> "4096.00"
Then
isEqual = False
Exit For
End If
Next
End With

If isEqual Then
' All are equal
Else
' All are not equal
End If
 
I know you have an arraylist. Was only an example. Doesn't change that you
need a loop.

Armin

well i think that would help. but the reason i just need to see if all
my readings are equal to 4096.00 then i need to set a set condition
that will pop up a message box. the problem is that i also look for
error on each port (4096 is an error). Do you know of anything in vb
2005?
 
cmdolcet69 said:
well i think that would help. but the reason i just need to see if
all my readings are equal to 4096.00 then i need to set a set
condition that will pop up a message box. the problem is that i also
look for error on each port (4096 is an error). Do you know of
anything in vb 2005?

I don't know what to say because I fail to see the problem.


Armin
 
A try withouth IDE and hoping that I understand you because your code is
probably as well not copied from an IDE.

\\\
Private function Inloop(parameter as String) as String
foreach item as string in readinglabelarralist
if item <> parameter return ""
next for
return parameter
end sub
///

The Ctype is then not needed because it returns a string

Cor
 
Back
Top