English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

For intSub=1 to 4
For intInnerSub=1 to 4
intSubNext = intInnerSub + 1
If (strFirstName(intInnerSub) > str First name(intSubNext) then
strSwap = strFirstName(intInnerSub)
strFirstName(intInnerSub) = strFirstName (intSubNext)
strFirstName(intSubNext) = strSwap
End If
Next intInnerSub
Next intSub

What does this code mean as a whole and what does each line of code perform? I cannot figure this out. By the way strFirstName is an array with five elements.

Thank you so much

2007-03-27 10:53:43 · 2 answers · asked by ostyman09 2 in Computers & Internet Programming & Design

2 answers

It's sorting the array alphabetically. The nested 'for' loops are to ensure that each element is inspected and put in the proper order. The 'if' statement is where it is testing to see if it is out of order, if it is then it puts one of the names into a buffer, moves the other name to the one it just copied and puts the copy into the second one; effectively swapping the two values. This is a typical sorting algorithm.

2007-03-27 12:24:19 · answer #1 · answered by Chris J 6 · 2 0

It puts a list of names in alphabetical order.

2007-03-27 17:58:09 · answer #2 · answered by coolestguyever21 3 · 1 0

fedest.com, questions and answers