Arraylist Index Question

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

    #1

    Arraylist Index Question

    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(newgraphi cs.readinglabel arralist(intloo p),
    label).test="40 96.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
    readinglabelarr aylist(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.
  • Armin Zingler

    #2
    Re: Arraylist Index Question

    "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb
    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(newgraphi cs.readinglabel arralist(intloo p),
    label).test="40 96.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
    readinglabelarr aylist(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.TrueForAl l(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

    Comment

    • Armin Zingler

      #3
      Re: Arraylist Index Question

      "Armin Zingler" <az.nospam@free net.deschrieb
      In VB 2008 you can do nice things like this:
      >
      dim b as boolean
      >
      b = Array.TrueForAl l(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

      Comment

      • cmdolcet69

        #4
        Re: Arraylist Index Question

        On Dec 7, 2:40 pm, "Armin Zingler" <az.nos...@free net.dewrote:
        "Armin Zingler" <az.nos...@free net.deschrieb
        >
        In VB 2008 you can do nice things like this:
        >
        dim b as boolean
        >
        b = Array.TrueForAl l(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
        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?

        Comment

        • Jack Jackson

          #5
          Re: Arraylist Index Question

          On Fri, 7 Dec 2007 11:16:46 -0800 (PST), cmdolcet69
          <colin_dolcetti @hotmail.comwro te:
          >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(newgraphi cs.readinglabel arralist(intloo p),
          >label).test="4 096.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
          >readinglabelar raylist(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 .readinglabelar ralist.count - 1
          If CType(.readingl abelarralist(in tloop), 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

          Comment

          • Armin Zingler

            #6
            Re: Arraylist Index Question

            "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb
            On Dec 7, 2:40 pm, "Armin Zingler" <az.nos...@free net.dewrote:
            "Armin Zingler" <az.nos...@free net.deschrieb
            In VB 2008 you can do nice things like this:
            dim b as boolean
            b = Array.TrueForAl l(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
            >
            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

            Comment

            • Cor Ligthert[MVP]

              #7
              Re: Arraylist Index Question

              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(paramete r as String) as String
              foreach item as string in readinglabelarr alist
              if item <parameter return ""
              next for
              return parameter
              end sub
              ///

              The Ctype is then not needed because it returns a string

              Cor



              "cmdolcet69 " <colin_dolcetti @hotmail.comsch reef in bericht
              news:a97664a9-e7a5-425e-9312-a9e9075af2c7@y4 3g2000hsy.googl egroups.com...
              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(newgraphi cs.readinglabel arralist(intloo p),
              label).test="40 96.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
              readinglabelarr aylist(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.

              Comment

              Working...