print the array values in ascending order?

Answers were Sorted based on User's Feedback



print the array values in ascending order?..

Answer / rajanikanth

Option Explicit
Dim a,i,b,j,temp
a=Array(30,70,10,60,90,20,50,80)

For i=0 To UBound(a)

For j=0 To UBound(a)

If StrComp(a(i),a(j),1)<0 Then
temp=a(i)
a(i)=a(j)
a(j)=temp
End If
Next
Next
For i=0 To UBound(a)
MsgBox a(i)
Next

Is This Answer Correct ?    1 Yes 0 No

print the array values in ascending order?..

Answer / 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

More VB Script Interview Questions

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

0 Answers  


Explain the functionality of vbscript?

0 Answers  


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

0 Answers  


There are 5 web pages.write a script to click the button on 4th web page.

0 Answers   Accenture,


How do you get the value of a combo box in Javascript?

2 Answers   Aspire,


What is the difference between a dictionary and an array?

0 Answers  


does anyone have qtp11.0 license key.Please sendit to my mail id-rrvv2011@gmail.com...Thanks

0 Answers  


Which in-built functions are used to convert the specified expression in the form of date and string in the vbscript language?

0 Answers  


what is resorceallocation

0 Answers  


how to store charecters of HARIBABU Using arrays

4 Answers   Cap Gemini,


How to write VB script for login module?

0 Answers  


i need to login to my yahoo accoutnt using VB Script, automating the operation of webobjects, even launching of IE. How?

1 Answers   Mphasis,


Categories