what is the code to search an array - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

what is the code to search an array

mad hattermad hatter Posts: 1Member
Hi

is there a general source code to search an array, and if so, could I please have the code
thanks

Comments

  • GideonOmegaGideonOmega Posts: 617Member
    : Hi
    :
    : is there a general source code to search an array, and if so, could I please have the code
    : thanks
    :

    The only way I know of to search through an array is using a for next loop like so

    [code]
    'Create array and counter
    dim intArray(4) as integer
    dim intCounter as integer

    ' Load array, you only go to 3 because arrays normaly start at 0
    'unless you set the following code you your general declarations:
    'Option base 1 - this will set your arrays to start at 1 instead of 0

    for intcounter = 0 to 3
    intarray(intcounter) = intcounter
    Next intcounter

    'Now to go through the array and return the value if 2 is found
    for intcounter = 0 to 3
    if intarray(intcounter) = 2 then
    strMessage = msgbox(" Number 2 Found!!!",vbOkOnly,me.caption)
    Exit for
    End if
    Next intcounter
    [/code]

    as you can imagine you can use variable values in various places to get the desiered results.


    I hope that is what you where asking, and I hope it Helps.
Sign In or Register to comment.