Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.