How to use While Do Loop in Crystal Reports
The following example searches for the first occurrence of a digit in an input string. If a digit is found, it returns its position, otherwise it returns -1. In this case, the input string is set explicitly to a string constant, but it could be set equal to a String type database field instead. For example, for the input String, “The 7 Dwarves”, the formula returns 5, which is the position of the digit 7.
Local StringVar inString := "The 7 Dwarves"; Local NumberVar strLen := Length (inString); Local NumberVar result := -1; Local NumberVar i := 1; While i <= strLen And result = -1 Do ( Local StringVar c := inString [i]; If NumericText (c) Then result := i; i := i + 1; ); result