print the array values in ascending order?

Answer Posted / cnu_thatavarthi

arr = Array(4, 6, 2, 7, 3, 5, 1, 8, 10, 22, 33, 15, 11, 8)

For i = LBound(arr) to UBound(arr)
For j = LBound(arr) to UBound(arr) - 1
If arr(j) > arr(j + 1) Then
TempValue = arr(j + 1)
arr(j + 1) = arr(j)
arr(j) = TempValue
End If
Next
Next

s = ""
For i = LBound(arr) To UBound(arr)
s = s & arr(i) & ","
Next

Msgbox s

'Expected output
---------------------------

---------------------------
1,2,3,4,5,6,7,8,8,10,11,15,22,33,
---------------------------
OK
---------------------------

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about the extension .hta?

621


what is event handling?

580


What are the uses of vb script?

585


how to automatically update the sql server2005 database records when insert in vb6?

1485


write a function to read the items from combobox of Flight reservation & save in excel (QTP)??

2391






If else for do while select in vb script?

640


Mention when to use function procedures and what are its characteristics?

627


Plzzzzzzz can any one tell me which is the best institute in hyderabad for learing VBScript. plz do answer guys its urgent plzzzzzzz. thanks in advance.

1721


What are the rules to name variable in vbscript?

587


What is the difference between javascript and vbscript?

532


I am working on QTP, got struck in one place.. In my application depending upon configuration WebEdit count is increasing/ decreasing.. how to get these webedits..

1801


write a program to display configuration of a local system with the help of vb script.

1684


Which object is used to work with the excel sheets in the vbscript language and what statement is used to create this object?

481


How to get the length of the string by making use of the string function?

562


What is the difference between vb debugger and the script debugger?

586