Counting in an Array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • IraqiAli
    New Member
    • Feb 2007
    • 19

    Counting in an Array

    ok - im really new at visual basic. i've only just started studying it.

    what i need to know is how to count how many times a certain value appears in the array (two dimentional).

    Dim ElectArr(1 To 20, 1 To 6)

    right now my two dimentional array is filled with 1's, 2's and 3's. what i need is a code that can count how many 1's there are in the first column. but im really stuck.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by IraqiAli
    ok - im really new at visual basic. i've only just started studying it.

    what i need to know is how to count how many times a certain value appears in the array (two dimentional).

    Dim ElectArr(1 To 20, 1 To 6)

    right now my two dimentional array is filled with 1's, 2's and 3's. what i need is a code that can count how many 1's there are in the first column. but im really stuck.
    Just use a For loop to go through the first "column" and examine each value. Each time you hit one that matches, add 1 to a counter variable.

    Comment

    • IraqiAli
      New Member
      • Feb 2007
      • 19

      #3
      Originally posted by Killer42
      Just use a For loop to go through the first "column" and examine each value. Each time you hit one that matches, add 1 to a counter variable.
      thank you - i tried it and it worked perfectly

      Comment

      Working...