06 November 2017

Multi demension Array in UFT ( different ways of initializing and accessing )

Option 1:

Dim arr(2,2)   
arr(0,0) = "1"
arr(0,1) = "2"
arr(0,2) = "3"
arr(1,0) = "4"
arr(1,1) = "5"
arr(1,2) = "6"
arr(2,0) = "7"
arr(2,1) = "8"
arr(2,2) = "9"

MsgBox arr(1,0)   'Return 4
MsgBoxUBound(arr,1)   'Return 2



Option 2:

a1 = Array(Array(1, 2, 3), Array(4, 5), Array(6, 7, 8, 9))

MsgBox a1(2)(0) 'Return 6
MsgBoxUBound(a1,1) 'Return 2



Option 3:

a  = array(2,1,4)
a(0)= Array(1,2,3)
a(1) = Array(4,5)
a(2) = Array(6,7,8,9)

MsgBox a(2)(0)   'Return 6
MsgBoxUBound(a,1)   'Return 2




Option 4:

Dim arr(2,4,8)   
arr(0,0,0) = "1"
arr(0,0,1) = "2"
arr(0,0,2) = "3"
arr(1,0,0) = "4"
arr(1,0,1) = "5"
arr(1,0,2) = "6"
arr(2,0,0) = "7"
arr(2,0,1) = "8"
arr(2,0,2) = "9"

MsgBox arr(1,0,1)   'Return 5
MsgBoxUBound(arr,1)   'Return 2
MsgBox arr(2,0,0)   'Return 7
MsgBoxUBound(arr,2)   'Return 4



...

No comments:

Post a Comment

AOM - Automation Object Model

'Creating QuicTest Object Set  qtapp =  createobject ( "QuickTest.Application" ) 'Launching the Application If  qtapp...