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

Like OPTION EXPLICIT statement what are the other statements used in vbscript and their usage. Please post me all the statements please.

0 Answers   Accenture,


Explain the scope of the variables using dim, public, and private keywords respectively.

0 Answers  


I want to run QTP script on Linux server is it possible to do this by connecting Windows to Linux through VPN/Terminal Server and just run the script on Linux server.

0 Answers  


i wrote vbscripit code in notepad i got error i am in learning stage if u ps tell me what wrong in my code my error is "object required descriptive at line one run time error"and my code is "set usernameobj=Descriptive.Create() usernameobj( "name").value="Username" set passwordobj=Descriptive.Create() passwordobj("name").value="password" set signinobj=Descriptive.Create() signinobj("name").value="sigin" browser("gmail").page("gmail").WebEdit("usernameobj").set ("enter username") Browser("gmail").Page("gmail").WebEdit("passwordobj").Set secure.Crypt.Encrypt("enter password") browser("gmail").page("gmail").WebButton("siginobj").click

0 Answers  


What is the purpose of folders object of scripting.filesystemobject class in vbscript?

0 Answers  


Can someone please tell me what poor design in a relational database (not the layout or style) is and how it can be avoided? PLEASE...im desperate.

0 Answers  


What are the valid scopes of a variable in vbscript?

0 Answers  


How to use Text file (Notepad) as ur data source in QTP? Can u please provide some function code for it?

1 Answers  


wat is the com(common object model)object for mozilla firefox???????plz if any one know the exact answer....reply me......

0 Answers  


What is the technology used by vb script?

0 Answers  


Program to use input box and send even numbers into sheet1 and odd numbers into sheet2 and prime numbers into sheet3 using vbscript(QTP)?

0 Answers   Tech Mahindra,


how to comvert 120 into one hunderd twenty rupees only and vice varsa

0 Answers  


Categories