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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How to use the object spy in quicktest professional 8.0 version?

544


Is virtual object supported in low level recording mode?

622


Connect to QC using AOM.

1234


Can the user toggle between using Local OR and shared OR for the same action?

559


How many types of trigger events are there in qtp?

549






can any body give the banking domain concepts/links

3633


What are the technologies supported by qtp?

562


I am getting an error "failed to open the XML checkpoint result viewer" in result window,after clicking on "View XML checkpoint results".Someone suggest me settings,if any...

1460


Shall we add Local Repository to shared object repository,if yes,how we add

5688


Where is the resultset of a sqlquery (which is fired by rsobj.open sqlquery,xxxx,xxxx) stored ?

1862


how to evalute defects in QTP script?

1488


What is the XML file architecture ?

1550


How to interact tool & application build in QTP?

1462


How to do the scripting. Is there any inbuilt functions in qtp as in qtp-s.

529


Explain how you can replace string in qtp?

605