Difference between Concept of Array in C and VBScript

    2
    26
    Spread the love
    • 1
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
      1
      Share

    Hi Guys,
    I am writting this post through cell phone.So please forgive me if spell anything wrongly. Today i got an idea of changing the concept of array in two different languages.

    Well,
    I was trying to execute a piece of code in QTP like..
    dim a(10)
    ….
    for i=0 to Ubound(a) ‘ a being an array
    msgbox a(i)
    next

    I was seeing the loop is actually running from 0 to 10.That mean it is running for 11 times.

    Check it out guys..
    But those who are from C programming background may find it faulty..isn’t it?????

    Even if we use a simple logic to loop through it is suppose to run 10 times!!!!!!!!!!!

    well i got an idea..

    For C
    The declaration int values[10]; would reserve enough space for an array called values that could hold up to 10 integers. Refer to the below given picture to conceptualize the reserved storage space.
    values[0]=””
    values[1]=””
    values[2]=””
    values[3]=””
    values[4]=””
    values[5]=””
    values[6]=””
    values[7]=””
    values[8]=””
    values[9]=””
    so this will loop through 0 to 9 that is 10 times….

    But For VB Script
    The concept is..
    Dim students(6) As Integer
    The array students in the preceding example contains 7 elements. The indexes of the elements range from 0 through 6. Having this array is simpler than declaring 7 different variables.
    The following illustration shows the array students. For each element of the array:
    The index of the element represents the grade (index 0 represents kindergarten).
    The value contained in the element represents the number of students in that grade.

    The array values stored in the memory.
    The example is taken from Microsoft

    So the bottom line is while using QTP or any other VB script Application please take care of this array concept.

    Don't miss out!
    Subscribe To Newsletter

    Receive top technical news, lesson ideas, travel tips and more!

    Invalid email address
    Give it a try. You can unsubscribe at any time.

    Spread the love
    • 1
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
      1
      Share

    2 COMMENTS

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here