'This code demonstrate how to find the highest number in a numaric array.

Dim num, i, Length1

num=array(34,12,98,43,89,49,56)

Length1 = UBound(num) 'Find the length of array

For i= 1 to Length1

If (num(i)

num(0)=num(i)

End If

Next

MsgBox num(0) 'Highest Number

Dim num, i, Length1

num=array(34,12,98,43,89,49,56)

Length1 = UBound(num) 'Find the length of array

For i= 1 to Length1

If (num(i)

**<**num(0)) Then 'to find lowest number, just change it to**>**num(0)=num(i)

End If

Next

MsgBox num(0) 'Highest Number

thanks Abhikansh..

ReplyDeletekeep it up!! :)

outstanding work....keep it up....

ReplyDeleteSuper!!

ReplyDeletei tried to pass numbers(5,10,15) in array to find the biggest number and getting as 5. but it should be 15. pls help me in this.

ReplyDeletenum=array("5","10","15")

Length1 = UBound(num)

For i= 1 to Length1

If (num(i)>num(0)) Then

num(0)=num(i)

End If

Next

MsgBox num(0)

@raghav,

ReplyDeleteplz dont use double qoutes while paasing values in array..

superb! whatever search here i can get solution here thanks dude

ReplyDeleteexcellent

ReplyDeleteplz help me... how to capture screen shot during runtime... what is syntax and explain plz

ReplyDelete@satish k

ReplyDeleteplz search CaptureBitmap in qtp help

Good Job :)

ReplyDeleteCool!

ReplyDeletefind the max value from array

ReplyDeleteDim x,y,max

x=array(50,20,30,40,90)

z=UBound(x)

max=0

For i = 0 To z

If x(i)>max Then

max=x(i)

End If

Next

MsgBox max

Yo can try this one also:

ReplyDeleteDim a, temp, i, j, firsthighest, secondhighest, thirdhighest

a = Array(35,44,99,66,98,76)

'Sorting the array in Ascending order

for i=0 to UBound(a)

for j=0 to UBound(a)

if (strcomp(a(i), a(j), 1)<0) then

temp = a(i)

a(i) = a(j)

a(j) = temp

end if

Next

Next

firsthighest = (UBound(a))

msgbox "First highest mark is: "&a(Firsthighest)

secondhighest = (UBound(a)-1)

msgbox "Second highest mark is: "&a(secondhighest)

temp = a(i)

Deletea(i) = a(j)

a(j) = temp

Please explain this portion.

I dint get these lines.....

ReplyDeletenum(i) is actually an number or index? why for loop started from 1 rather 0

For i= 1 to Length1

If (num(i)>num(0)) Then

num(0)=num(i)

End If

Next

The above code should be start little bit we need to correct

ReplyDeleteFor i = 0 to Length

How can i sort larger number to lowest? but user input the numbers in arry

ReplyDelete