how to find the ascending order and descending order in array using vbscript

3,843 views
Skip to first unread message

vijay kanaparthi

unread,
Apr 1, 2013, 1:51:28 AM4/1/13
to mercu...@googlegroups.com
Hi,

how to find the ascending order and  descending order in array using vbscript

--
Thanks & Regards,
  Vijay
   9916686756

lalit aggarwal

unread,
Apr 1, 2013, 2:08:57 AM4/1/13
to mercu...@googlegroups.com
Hi Vijay,

Do you want to sort an array in ascending or descending order or just check the array whether is it in ascending or descending order?
if you want to sort an array you can write a small code for it like

for ascending order.

For  I = 0 to ubound (array) -1

                For j = I + 1 to ubound (array)

                                If array(i) > array(j) then

                                Temp  = array(i)

                                Array(i) = array(j)

                                Array(j) = temp

                Next

Next

I hope I clears you doubt up to some extend

Regards,

Lalit Aggarwal

9900329906



--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
 
---
You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mercuryqtp+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

fakruddin baba

unread,
Feb 24, 2014, 10:12:16 AM2/24/14
to mercu...@googlegroups.com
Hi, To check whether the function is in ascending or descending order. you can use below function directly.

Function fn_ValidateArrayOrder(arrInput, strOrderType)
    Dim blnFlag
    blnFlag = False
    Select Case UCase(strOrdertype)
        Case "ASCENDING"
            For i = 0 to Ubound(arrCRAAcntNos)-1
                If StrComp(arrInput(i), arrInput(i+1), 1) = -1 Then
                    blnFlag = True
                End If
            Next
        Case "DESCEDING"
            For i = 0 to Ubound(arrCRAAcntNos)-1
                If StrComp(arrInput(i), arrInput(i+1), 1) = 1 Then
                    blnFlag = True
                End If
            Next
    End Select
    If blnFlag Then
        fn_ValidateArrayOrder = blnFlag
    End If
End Function

Regards,
baba

fakruddin baba

unread,
Feb 24, 2014, 10:21:13 AM2/24/14
to mercu...@googlegroups.com

Function fn_ValidateArrayOrder(arrInput, strOrderType)
    Dim blnFlag, i
Reply all
Reply to author
Forward
0 new messages