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

Problem with XML checkpoint in QTP ?

3603


Is there any pdf or online book for QTP Scripting? Let me know more about QTP Scripting.

2502


how to fetch the values from grid? & qtp recogniges that grid as a webelement? what u do?

2023


What is the difference between local and shared object repository in qtp?

644


Give the syntax to load function at run time.

738






What is the extension of the qtp local repository? If it is .mtr then what is .bdb extension stands for?

673


Have you used xml check point in your project?

639


how to find that tools work well with ur existing system?

1465


How to carry out bit map check points in QTP

1845


What is QTP testing process?

702


For which type of project the iterative model is suitable?

1456


can any body give the banking domain concepts/links

3719


what r the main attributes of test automation?

1567


How many types of actions are there in quicktest professional (qtp)?

626


How many types of recording modes in qtp?

686