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

how to convert 100 into hundred repees only and viceversa

0 Answers  


HOW to invoke any recorded script in QTP with out using RECORD & PLAYBACK CONCEPT?

3 Answers   CTS,


What is QTP and the use of QTP in TD?

0 Answers   MaxSolPro,


What is the difference between Datadriven and Parameterization?

8 Answers   Ordain Solutions,


Diff b/w test scenario's and test Procedures?

0 Answers  






How to find Total no of Text Fields in the Page..Anybody please answer me..Thanks in Advance

2 Answers   BirlaSoft,


What is object & properties (in QTP)

5 Answers   Ordain Solutions,


Explain the concept of object repository and how QTP recognizes objects?

0 Answers  


As u told write Libarary files in QTP. Do u use ever oject repositary 0r spy while writing scripts and for which type of testing u prepared test scripts.

1 Answers  


how to capture tool tip in QTP and which check point is needed

2 Answers   Syntel,


Is virtual object supported in low level recording mode?

0 Answers  


What is the Limitations of Testing ?

4 Answers   TCS,


Categories