Write the vb script for the lowest and highest values of an
array?



Write the vb script for the lowest and highest values of an array?..

Answer / pramod mallick

Dim x(5)

x(0) = 1
x(1) = 3
x(2) = 3
x(3) = 5
x(4) = 2


Dim y
Dim strArray

'Display
For y = LBound(x) To UBound(x)
strArray = strArray & x(y) & ","
Next

MsgBox "Before Sorting " & strArray

Dim z
'Demo loop
For z = LBound(x) To UBound(x)

For y = LBound(x) To UBound(x) - 1

Dim lower As Integer
Dim higher As Integer

If x(y) > x(y + 1) Then
higher = x(y)
lower = x(y + 1)
x(y) = lower
x(y + 1) = higher
ElseIf x(y) > x(y + 1) Then
higher = x(y)
lower = x(y + 1)
x(y) = lower
x(y + 1) = higher
Else 'equal
'do nothing
End If

Next
Next


'Display
strArray = ""
For y = LBound(x) To UBound(x)
strArray = strArray & x(y) & ","
Next

MsgBox "After sorting " & strArray

msgbox "Lowest is " & Lbound(x) & "Highest is " Ubound(x)

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More QTP Interview Questions

Syntact for how to call one script from another? and Syntax to call one "Action" in another?

1 Answers  


What are the Features & Benefits of Quick Test Pro ?

0 Answers   Crea,


Hi we are running tests remotely from quality center and pushing tests into qtp boxes remotely, and it does execution but while uploading results back into quality center it hangs in qtp box.If any one come across similar problem, please send me details how to handle this. Thanks kris

0 Answers  


I want to know can we integrate visual source safe tool with QTP and QC for our version controlling process? WE know QTP and QC 10.0 version is having the version control inbuilt in it but I want to know the merits and demerits of the inbuilt version control tool and the visual source safe tool using QTP and QC.

0 Answers   Wipro,


write a script to verify links on any web page by using descriptive method by creating a description object (give a filter condition only link) ... need to verify expected like name by reading

0 Answers  






how can we call an external library file in QTP apart from using the Executefile statement..?? is there any other way we can call the external library file in QTP..??

2 Answers   DST Global Solutions,


Please give me the steps to carry out datadriven in QTP8.2

2 Answers  


In Manual testing , can u prpare bug report in TD?

1 Answers   TCS,


What are the challenges do we face while testing webbased applcations using the automation tool QTP or any?

1 Answers  


object types is used for what?

1 Answers  


How to explain a banking project in interview as a test engineer???

0 Answers   Accenture,


Hai anyone please "Explain about Framework in QTP?"

0 Answers  


Categories