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

Inserting a Call to Action is not importing all columns in Datatable of globalsheet. Why?

1 Answers   Crea,


RECENTLY I PLACED IN QTP..HOW TO IMPROVE VB SCRIPTS KNOWLEDGE? IAM STRUGGING TO WRITE THE AUTOMATION SCRIPTS? ANY BODY TELL HOW TO IMPROVE QTP SCRIPT SKILLS?

0 Answers  


What is qtpro? What is a quick test professional?

0 Answers  


Hello, I am learning QTP. I have recorded test for Login page, i have also inserted checkpoint for Email field & when I run test it passed. But when i tried to run test by inserting 'Adding Parameter Values to a Data Table' for email & password field, it pass the first value in both the fields but after that when test run for second parameter values it displays 'Internet Explorer cannot open the Internet site, Operation aborted' & when i analyze test result it displays run time error 'Object disable'. I have also cleared all the history from IE but it is not working. Please help me. Thank you.

2 Answers  


Is it possible to return multiple values from a function..? Then how..?

3 Answers  






Does QTP supports Linux or Unix OS?.If so which scripting is preferable? Shell we do record and playback

1 Answers  


Can we call a parameter from an action to other action?

4 Answers  


four browser are open same application i want to enter 3browser how?

3 Answers   IBM,


what is the mediater between qtp and application/project in automation testing?

1 Answers  


What are table and db checkpoints?

0 Answers  


tell me exact differenceb bw qtp and selenium?(could not tell open soure and licennce? difference in usage and technical difference?

0 Answers  


Could you please any one give code for the following ? Scenario : Suppose a excel file contains 10 records and earch have 5 fields. how can i input this excel file for datadrive wizard ? Please explain

0 Answers  


Categories