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

write script to open Gmail.com, and to write script for entering username and password and show whether the result as pass or fail

2 Answers   Thomson Reuters,


create a form to accept username and password validate the username and password with using message box, display the corresponding user message

0 Answers   CSC,


How are values assigned to string type and numeric type variables?

0 Answers  


What is the difference between do until loop and do while loop?

0 Answers  


Hi everybady, i have faced few Qns in one of i attended interview, please help me out with these below Qns. 1. how to join values without using join function? 2. how to compare values without using String compare function? 3. input is Bangalore, but i need output like this below format, what is function to use and get this outcome B A N G A L o R E 4. Input is "CapGemini" but uotput should be like this "inimeGpaC" 5. Input is 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Can someone let me know results of this Qns, please. Thanks.

2 Answers   CSS Corp,






I am running a windows based application.While running the script on QTP ,The Application pop-up an Error Message as "object Disabled" in two different scenarios Scenario 1-->The Application pop-up up a Message for Max Session Reached(as the application is set to hold 2 session and if if crosses the pre-defined limit then the error message pop-up) Scenario 2-->When Network connectivity is disabled the Application screen gets greyed out in colour with no operation possible. Now through Exception handling features in QTP ,we need to do the following For Scenarion 1-->Through Exception handling we need to just accept the Message pop-up in the Application and and resume with the call function as is for Scenario 2--> Through Exception Handling featutes on QTP we need to shut down the client , restart the client and resume the call functions as it is Note: The Application returns an Error Message as "object disabled" in both the cases i.e for pop-up message and when the Apllication getting greyed out due to Network failure how can we enhance the script in such a way that for the same error message retured by the application in two different and how to handle them????

2 Answers   Sasken,


What are subprocedures in vbscript?

0 Answers  


can anyone send me a vb scripts code for clicking on a link and coming back on home page again does the same for many links on a web page.

0 Answers   Synechron,


which is the bset training centre to learn automation tools?

2 Answers  


What is the extension of the vbscript file?

0 Answers  


Hi I am having one folder with set of text files now i want to read and write that text files data into QTP. Any help plsss.

1 Answers  


Join the multiple array with out using JOIN function

1 Answers  


Categories