Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I iterate through an array of strings using VB?

Tags:

arrays

vb6

Here's my code so far:

Dim i As Integer
Dim stringArray() as String

stringArray = split("Hello|there", "|")

For i = 0 To stringArray.Length()
   ' Logic goes here
Next

VB6 doesn't seem to like me using stringAray.Length() and gives me a compile error message like Invalid Qualifier, but what's the right way to iterate through each element of a string array?

like image 671
SpartaSixZero Avatar asked Jan 21 '14 13:01

SpartaSixZero


People also ask

Which activities allow you to iterate through an array of strings?

For each loop is used for traversing various items. A while loop on the other hand is generally a control flow statement which allows code to be executed repeatedly.

How do you iterate through an array?

Iterating over an array You can iterate over an array using for loop or forEach loop. Using the for loop − Instead on printing element by element, you can iterate the index using for loop starting from 0 to length of the array (ArrayName. length) and access elements at each index.

Which loop is used to iterate over arrays and strings?

The for..of loop in JavaScript allows you to iterate over iterable objects (arrays, sets, maps, strings etc).


1 Answers

ubound() returns the upper bounds;

Dim i As Long
Dim stringArray(1) as String

stringArray(0) = "hello"
stringArray(1) = "world"

For i = 0 To ubound(stringArray)
   msgbox(stringArray(i))
Next
like image 162
Alex K. Avatar answered Oct 28 '22 05:10

Alex K.