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

what is event handling?

586


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

1489


What are the different types of operators and their order of precedence?

574


wht must be the interview question on corinthian information technology solutions incorporated.

2188


How to replace junk code recorded by QTP with a mall function.

1649






Which operator can be used to change the value of the operand or change the state of the condition?

581


If else for do while select in vb script?

645


Write a test case using Test if the images,a particular test exists,check if the page links match,page response is within a certain range,parameterization of the test,the test should comprise of actions,the test should use a custom function,the test should use global repository

1796


What is the use of the recordset object and which statement is used to create such an object?

531


PLz send me the VB scripts which is having more examples my email id : hareen_11@yahoo.com

1667


Explain some uses of vb script?

556


Mention what is variant in vbscript?

561


How to throw an error in vbscript?

610


i am having some basic knowledge in c and VB 6.0. i qtp i want to know how to write the codings. by recording it is generating lot of codings. for example i want to test the text box. senerio is text box should not accept alphabets if it accept alphabets we should return fail status if it get number we should return pass status. how to write coding in vb script please help me

1801


How to use QTP Object in .vbs(vbscript file) file Ex: Browser().., wait(), exist() and etc...

2905