The ArrayList is a type of collection. These allow dynamic resizing. ArrayLists are actual objects. Therefore, we must define them like this:
ArrayLists are not strongly typed. This means (although not recommended) you can put different datatypes into a single ArrayList. For example:
NOTE: Again, using ArrayLists in this way is bad programming and is NOT recommended. Only do this if you absolutely have to.
To retrieve a value from an ArrayList, we use another variable. For example:
In this scenario, we set the value of the string FirstItem as the value of the first value (0) in the ArrayList listName. When using an ArrayList in this way, we must use the CType function to ensure the value of the object is the correct type of object. The CType function takes a value and converts it to the specified variable type (in this case a String).
Previous Next