If statements or a sequence of statements must be repeated in a statement block, you can use the following selected control structures described in this chapter. In the list you will find only the short, synonymous descriptions.
The control structures are called Repeat, Iteration or Loop/.
Example for the use of 3 different control structures (WHILE..WEND, FOR..TO..STEP..NEXT and FOR EACH..IN..NEXT) in one function:
Private Function IsPolynomial(sInput As String) As Boolean Dim sPattern, sTerm As String Dim aResult, aTmp As New String[] Dim iI, iJ As Integer Dim sExpression As String sInput = Trim(sInput) sInput = Replace$(sInput, Left$(Format$(0, ".0")), ".") aResult = Split(sInput, "+", "", True) iI = 0 While iI < aResult.Count sExpression = IIf(aResult[iI] Not Begins "-", "+", "") & aResult[iI] aResult.Remove(iI) aTmp = Split(sExpression, "-", "", True) For iJ = 0 To aTmp.Max Step 1 aTmp[iJ] = IIf(aTmp[iJ] Not Begins "+", "-", "") & aTmp[iJ] Next ' iJ aResult.Insert(aTmp, iI) iI += aTmp.Count Wend sPattern = "^[+-]?([0-9]+(\\.[0-9]+)?)?(x([\\^][0-9]+)?)?$" For Each sTerm In aResult If sTerm Not Match sPattern Then Return False Endif ' Match Pattern Next ' sTerm Return True End