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
How to use the object spy in quicktest professional 8.0 version?
Is virtual object supported in low level recording mode?
Connect to QC using AOM.
Can the user toggle between using Local OR and shared OR for the same action?
How many types of trigger events are there in qtp?
can any body give the banking domain concepts/links
What are the technologies supported by qtp?
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...
Shall we add Local Repository to shared object repository,if yes,how we add
Where is the resultset of a sqlquery (which is fired by rsobj.open sqlquery,xxxx,xxxx) stored ?
how to evalute defects in QTP script?
What is the XML file architecture ?
How to interact tool & application build in QTP?
How to do the scripting. Is there any inbuilt functions in qtp as in qtp-s.
Explain how you can replace string in qtp?