home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / LVB / T2W32543.ZIP / _ARRAY.FRM next >
Text File  |  1998-05-21  |  44KB  |  1,677 lines

  1. VERSION 5.00
  2. Begin VB.Form frmArray 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Array"
  5.    ClientHeight    =   5670
  6.    ClientLeft      =   1185
  7.    ClientTop       =   1515
  8.    ClientWidth     =   7710
  9.    MaxButton       =   0   'False
  10.    MDIChild        =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   5670
  13.    ScaleWidth      =   7710
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.Frame Frame1 
  16.       Height          =   570
  17.       Left            =   0
  18.       TabIndex        =   3
  19.       Top             =   -90
  20.       Width           =   7725
  21.       Begin VB.CommandButton cmdNP 
  22.          Caption         =   ">"
  23.          Height          =   285
  24.          Index           =   1
  25.          Left            =   7380
  26.          TabIndex        =   8
  27.          Top             =   195
  28.          Width           =   285
  29.       End
  30.       Begin VB.CommandButton cmdNP 
  31.          Caption         =   "<"
  32.          Height          =   285
  33.          Index           =   0
  34.          Left            =   6480
  35.          TabIndex        =   7
  36.          Top             =   195
  37.          Width           =   285
  38.       End
  39.       Begin VB.CommandButton Command1 
  40.          Caption         =   "&Go"
  41.          Default         =   -1  'True
  42.          Height          =   285
  43.          Left            =   6840
  44.          TabIndex        =   6
  45.          Top             =   195
  46.          Width           =   465
  47.       End
  48.       Begin VB.ComboBox cmb_Function 
  49.          Height          =   315
  50.          Left            =   1365
  51.          TabIndex        =   4
  52.          Top             =   180
  53.          Width           =   4935
  54.       End
  55.       Begin VB.Label Label2 
  56.          Caption         =   "&Select a function"
  57.          Height          =   255
  58.          Left            =   90
  59.          TabIndex        =   5
  60.          Top             =   210
  61.          Width           =   1275
  62.       End
  63.    End
  64.    Begin VB.ListBox List2 
  65.       Height          =   2205
  66.       Left            =   3960
  67.       TabIndex        =   2
  68.       Top             =   3360
  69.       Width           =   3675
  70.    End
  71.    Begin VB.ListBox List1 
  72.       Height          =   2205
  73.       Left            =   90
  74.       TabIndex        =   1
  75.       Top             =   3360
  76.       Width           =   3675
  77.    End
  78.    Begin VB.Label lbl_Result 
  79.       Appearance      =   0  'Flat
  80.       BackColor       =   &H00C0C0C0&
  81.       ForeColor       =   &H80000008&
  82.       Height          =   2595
  83.       Left            =   105
  84.       TabIndex        =   0
  85.       Top             =   630
  86.       Width           =   7485
  87.    End
  88. End
  89. Attribute VB_Name = "frmArray"
  90. Attribute VB_GlobalNameSpace = False
  91. Attribute VB_Creatable = False
  92. Attribute VB_PredeclaredId = True
  93. Attribute VB_Exposed = False
  94. Option Explicit
  95. Option Base 1
  96.  
  97. Private Const Iteration = 250
  98.  
  99. Private Const arrSize = 10
  100.  
  101. Dim IsLoaded         As Integer
  102.  
  103. Dim TimerStartOk     As Integer
  104. Dim TimerCloseOk     As Integer
  105.  
  106. Dim TimerHandle      As Integer
  107. Dim TimerValue       As Long
  108.  
  109. Private Type tagTESTARRAY
  110.    i1       As Long
  111.    i2       As Integer
  112.    i3       As String
  113. End Type
  114.  
  115. Private Type tagTESTVTARRAY
  116.    v1       As Variant
  117.    v2       As Variant
  118.    v3       As Variant
  119. End Type
  120.  
  121. Private Sub TestAdd()
  122.    
  123.    Dim intResult        As Integer
  124.    Dim strDisplay       As String
  125.    
  126.    Dim intLB            As Integer
  127.    Dim intUB            As Integer
  128.    Dim intTotalElement  As Integer
  129.    
  130.    Dim i                As Integer
  131.    
  132.    intResult = False
  133.    strDisplay = ""
  134.    
  135.    ReDim Iarray(arrSize) As Integer
  136.    Randomize Timer
  137.  
  138.    intLB = LBound(Iarray)
  139.    intUB = UBound(Iarray)
  140.    intTotalElement = intUB - intLB + 1
  141.       
  142.    For i = intLB To intUB
  143.       Iarray(i) = RandI * Rnd(1)
  144.       List1.AddItem "" & Iarray(i)
  145.    Next i
  146.  
  147.    intResult = cAddI(Iarray(), 10)
  148.  
  149.    For i = intLB To intUB
  150.       List2.AddItem "" & Iarray(i)
  151.    Next i
  152.  
  153.    strDisplay = strDisplay & "Add 10 to element " & intLB & " of an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
  154.    strDisplay = strDisplay & "Add 10 to element " & intUB & " of an integer array is : " & Iarray(intUB)
  155.    
  156.    lbl_Result = strDisplay
  157.  
  158.    'time the function
  159.  
  160.    TimerHandle = cTimerOpen()
  161.    TimerStartOk = cTimerStart(TimerHandle)
  162.    
  163.    For i = 1 To Iteration
  164.       intResult = cAddI(Iarray(), 1)
  165.    Next i
  166.    
  167.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  168.    
  169.    TimerCloseOk = cTimerClose(TimerHandle)
  170.  
  171. End Sub
  172. Private Sub cmb_Function_Click()
  173.    
  174.    If (IsLoaded = False) Then Exit Sub
  175.    
  176.    Call cDisableFI(mdiT2W.Picture1)
  177.    
  178.    List1.Visible = True
  179.    List2.Visible = True
  180.    
  181.    List1.Clear
  182.    List2.Clear
  183.    
  184.    lbl_Result = ""
  185.    
  186.    DoEvents
  187.    
  188.    Select Case cmb_Function.ListIndex
  189.       Case 0
  190.          Call TestAdd
  191.       Case 1
  192.          List2.Visible = False
  193.          Call TestCount
  194.       Case 2
  195.          List2.Visible = False
  196.          Call TestDeviation
  197.       Case 3
  198.          Call TestFill
  199.       Case 4
  200.          Call TestFillIncr
  201.       Case 5
  202.          Call TestMax
  203.       Case 6
  204.          List2.Visible = False
  205.          Call TestMean
  206.       Case 7
  207.          Call TestMin
  208.       Case 8
  209.          Call TestReverseSort
  210.       Case 9
  211.          Call TestSearch
  212.       Case 10
  213.          Call TestSet
  214.       Case 11
  215.          Call TestSort
  216.       Case 12
  217.          List2.Visible = False
  218.          Call TestSum
  219.       Case 13
  220.          Call TestArrayOnDisk
  221.       Case 14
  222.          Call TestMaxNotX
  223.       Case 15
  224.          Call TestMinNotX
  225.       Case 16
  226.          Call TestSortTypedArray(STA_VARSTRING_CI, 1) 'case insensitive and ascending
  227.       Case 17
  228.          Call TestSortTypedArray(STA_VARSTRING_CI, -1) 'case insensitive and descending
  229.       Case 18
  230.          Call TestSortTypedArray(STA_VARSTRING_CS, 1) 'case sensitive and ascending
  231.       Case 19
  232.          Call TestSortTypedArray(STA_VARSTRING_CS, -1) 'case sensitive and descending
  233.       Case 20
  234.          Call TestSortTypedArray2(1)    'string as number
  235.       Case 21
  236.          Call TestSortTypedArray2(-1)   'string as number
  237.       Case 22
  238.          Call TestSortTypedArray3(STA_VT_VARSTRING_CI, 1) 'case insensitive and ascending
  239.       Case 23
  240.          Call TestSortTypedArray3(STA_VT_VARSTRING_CI, -1) 'case insensitive and descending
  241.       Case 24
  242.          Call TestSortTypedArray3(STA_VT_VARSTRING_CS, 1) 'case sensitive and ascending
  243.       Case 25
  244.          Call TestSortTypedArray3(STA_VT_VARSTRING_CS, -1) 'case sensitive and descending
  245.       Case 26
  246.          Call TestShiftLeft
  247.       Case 27
  248.          Call TestShiftRight
  249.       Case 28
  250.          Call TestRmvDup
  251.       Case 29
  252.          Call TestSearchStr
  253.       Case 30
  254.          Call TestArrayLookUp
  255.    End Select
  256.  
  257.    DoEvents
  258.    Call cEnableFI(mdiT2W.Picture1)
  259.    
  260. End Sub
  261.  
  262.  
  263. Private Sub cmdNP_Click(Index As Integer)
  264.  
  265.    Call sub_NextPrev(cmb_Function, Index)
  266.  
  267. End Sub
  268.  
  269. Private Sub Form_Activate()
  270.  
  271.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  272.  
  273. End Sub
  274.  
  275.  
  276. Private Sub Form_Load()
  277.  
  278.    IsLoaded = False
  279.    
  280.    Show
  281.  
  282.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_array.t2w")
  283.    
  284.    IsLoaded = True
  285.    
  286. End Sub
  287.  
  288. Private Sub TestDeviation()
  289.   
  290.    Dim dblResult        As Double
  291.    Dim strDisplay       As String
  292.    
  293.    Dim intLB            As Integer
  294.    Dim intUB            As Integer
  295.    Dim intTotalElement  As Integer
  296.    
  297.    Dim i                As Integer
  298.    
  299.    Dim dblMean          As Double
  300.    Dim dblDeviation     As Double
  301.    
  302.    dblResult = 0
  303.    strDisplay = ""
  304.    
  305.    dblMean = 0
  306.    dblDeviation = 0
  307.    
  308.    ReDim Iarray(arrSize) As Integer
  309.    Randomize Timer
  310.  
  311.    intLB = LBound(Iarray)
  312.    intUB = UBound(Iarray)
  313.    intTotalElement = intUB - intLB + 1
  314.       
  315.    For i = intLB To intUB
  316.       Iarray(i) = Int(RandI * Rnd(1))
  317.       dblMean = dblMean + Iarray(i)
  318.       List1.AddItem "" & Iarray(i)
  319.    Next i
  320.    
  321.    dblMean = dblMean / (intTotalElement)
  322.  
  323.    For i = intLB To intUB
  324.       dblDeviation = dblDeviation + ((Iarray(i) - dblMean) * (Iarray(i) - dblMean))
  325.    Next i
  326.    dblDeviation = (Sqr(dblDeviation) / (intTotalElement))
  327.    
  328.    dblResult = cDeviationI(Iarray())
  329.  
  330.    strDisplay = "The Deviation of a integer array of " & (intTotalElement) & " elements is " & vbCrLf & vbCrLf & dblResult & " (" & dblDeviation & ")"
  331.    
  332.    lbl_Result = strDisplay
  333.  
  334.    'time the function
  335.  
  336.    TimerHandle = cTimerOpen()
  337.    TimerStartOk = cTimerStart(TimerHandle)
  338.    
  339.    For i = 1 To Iteration
  340.       dblResult = cDeviationI(Iarray())
  341.    Next i
  342.    
  343.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  344.    
  345.    TimerCloseOk = cTimerClose(TimerHandle)
  346.  
  347. End Sub
  348.  
  349. Private Sub TestFill()
  350.    
  351.    Dim intResult        As Integer
  352.    Dim strDisplay       As String
  353.    
  354.    Dim intLB            As Integer
  355.    Dim intUB            As Integer
  356.    Dim intTotalElement  As Integer
  357.    
  358.    Dim i                As Integer
  359.    
  360.    intResult = False
  361.    strDisplay = ""
  362.    
  363.    ReDim Iarray(arrSize) As Integer
  364.    Randomize Timer
  365.  
  366.    intLB = LBound(Iarray)
  367.    intUB = UBound(Iarray)
  368.    intTotalElement = intUB - intLB + 1
  369.       
  370.    For i = intLB To intUB
  371.       Iarray(i) = RandI * Rnd(1)
  372.       List1.AddItem "" & Iarray(i)
  373.    Next i
  374.  
  375.    intResult = cFillI(Iarray(), 5)
  376.  
  377.    For i = intLB To intUB
  378.       List2.AddItem "" & Iarray(i)
  379.    Next i
  380.  
  381.    strDisplay = strDisplay & "Fill 1 to element " & intLB & " of an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
  382.    strDisplay = strDisplay & "Fill 1 to element " & intUB & " of an integer array is : " & Iarray(intUB)
  383.    
  384.    lbl_Result = strDisplay
  385.  
  386.    'time the function
  387.  
  388.    TimerHandle = cTimerOpen()
  389.    TimerStartOk = cTimerStart(TimerHandle)
  390.    
  391.    For i = 1 To Iteration
  392.       intResult = cFillI(Iarray(), 1)
  393.    Next i
  394.    
  395.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  396.    
  397.    TimerCloseOk = cTimerClose(TimerHandle)
  398.  
  399. End Sub
  400.  
  401. Private Sub TestFillIncr()
  402.    
  403.    Dim intResult        As Integer
  404.    Dim strDisplay       As String
  405.    
  406.    Dim intLB            As Integer
  407.    Dim intUB            As Integer
  408.    Dim intTotalElement  As Integer
  409.    
  410.    Dim i                As Integer
  411.    
  412.    intResult = False
  413.    strDisplay = ""
  414.    
  415.    ReDim Iarray(arrSize) As Integer
  416.    Randomize Timer
  417.  
  418.    intLB = LBound(Iarray)
  419.    intUB = UBound(Iarray)
  420.    intTotalElement = intUB - intLB + 1
  421.       
  422.    For i = intLB To intUB
  423.       Iarray(i) = RandI * Rnd(1)
  424.       List1.AddItem "" & Iarray(i)
  425.    Next i
  426.  
  427.    intResult = cFillIncrI(Iarray(), -2, 3)
  428.  
  429.    For i = intLB To intUB
  430.       List2.AddItem "" & Iarray(i)
  431.    Next i
  432.  
  433.    strDisplay = strDisplay & "Fill -2 by increment 3 to element " & intLB & " of an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
  434.    strDisplay = strDisplay & "Fill -2 by increment 3 to element " & intUB & " of an integer array is : " & Iarray(intUB)
  435.    
  436.    lbl_Result = strDisplay
  437.  
  438.    'time the function
  439.  
  440.    TimerHandle = cTimerOpen()
  441.    TimerStartOk = cTimerStart(TimerHandle)
  442.    
  443.    For i = 1 To Iteration
  444.       intResult = cFillIncrI(Iarray(), -2, 3)
  445.    Next i
  446.    
  447.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  448.    
  449.    TimerCloseOk = cTimerClose(TimerHandle)
  450.  
  451. End Sub
  452.  
  453. Private Sub TestMax()
  454.    
  455.    Dim intResult        As Integer
  456.    Dim strDisplay       As String
  457.    
  458.    Dim intLB            As Integer
  459.    Dim intUB            As Integer
  460.    Dim intTotalElement  As Integer
  461.    
  462.    Dim i                As Integer
  463.    
  464.    intResult = False
  465.    strDisplay = ""
  466.    
  467.    ReDim Iarray(arrSize) As Integer
  468.    Randomize Timer
  469.  
  470.    intLB = LBound(Iarray)
  471.    intUB = UBound(Iarray)
  472.    intTotalElement = intUB - intLB + 1
  473.       
  474.    For i = intLB To intUB
  475.       Iarray(i) = RandI * Rnd(1)
  476.       List1.AddItem "" & Iarray(i)
  477.    Next i
  478.  
  479.    intResult = cSortI(Iarray())
  480.  
  481.    For i = intLB To intUB
  482.       List2.AddItem "" & Iarray(i)
  483.    Next i
  484.    
  485.    intResult = cMaxI(Iarray())
  486.  
  487.    strDisplay = strDisplay & "The Max of this integer array is : " & intResult
  488.    
  489.    lbl_Result = strDisplay
  490.  
  491.    'time the function
  492.  
  493.    TimerHandle = cTimerOpen()
  494.    TimerStartOk = cTimerStart(TimerHandle)
  495.    
  496.    For i = 1 To Iteration
  497.       intResult = cMaxI(Iarray())
  498.    Next i
  499.    
  500.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  501.    
  502.    TimerCloseOk = cTimerClose(TimerHandle)
  503.  
  504. End Sub
  505.  
  506. Private Sub TestMin()
  507.    
  508.    Dim intResult        As Integer
  509.    Dim strDisplay       As String
  510.    
  511.    Dim intLB            As Integer
  512.    Dim intUB            As Integer
  513.    Dim intTotalElement  As Integer
  514.    
  515.    Dim i                As Integer
  516.    
  517.    intResult = False
  518.    strDisplay = ""
  519.    
  520.    ReDim Iarray(arrSize) As Integer
  521.    Randomize Timer
  522.  
  523.    intLB = LBound(Iarray)
  524.    intUB = UBound(Iarray)
  525.    intTotalElement = intUB - intLB + 1
  526.       
  527.    For i = intLB To intUB
  528.       Iarray(i) = RandI * Rnd(1)
  529.       List1.AddItem "" & Iarray(i)
  530.    Next i
  531.  
  532.    intResult = cSortI(Iarray())
  533.  
  534.    For i = intLB To intUB
  535.       List2.AddItem "" & Iarray(i)
  536.    Next i
  537.    
  538.    intResult = cMinI(Iarray())
  539.  
  540.    strDisplay = strDisplay & "The Min of this integer array is : " & intResult
  541.    
  542.    lbl_Result = strDisplay
  543.  
  544.    'time the function
  545.  
  546.    TimerHandle = cTimerOpen()
  547.    TimerStartOk = cTimerStart(TimerHandle)
  548.    
  549.    For i = 1 To Iteration
  550.       intResult = cMinI(Iarray())
  551.    Next i
  552.    
  553.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  554.    
  555.    TimerCloseOk = cTimerClose(TimerHandle)
  556.  
  557. End Sub
  558.  
  559. Private Sub TestMean()
  560.   
  561.    Dim dblResult        As Double
  562.    Dim strDisplay       As String
  563.    
  564.    Dim intLB            As Integer
  565.    Dim intUB            As Integer
  566.    Dim intTotalElement  As Integer
  567.    
  568.    Dim i                As Integer
  569.    
  570.    Dim dblMean          As Double
  571.   
  572.    dblResult = 0
  573.    strDisplay = ""
  574.    
  575.    dblMean = 0
  576.    dblMean = 0
  577.    
  578.    ReDim Iarray(arrSize) As Integer
  579.    Randomize Timer
  580.  
  581.    intLB = LBound(Iarray)
  582.    intUB = UBound(Iarray)
  583.    intTotalElement = intUB - intLB + 1
  584.       
  585.    For i = intLB To intUB
  586.       Iarray(i) = Int(RandI * Rnd(1))
  587.       dblMean = dblMean + Iarray(i)
  588.       List1.AddItem "" & Iarray(i)
  589.    Next i
  590.    
  591.    dblMean = dblMean / (intTotalElement)
  592.  
  593.    dblResult = cMeanI(Iarray())
  594.  
  595.    strDisplay = "The Mean of this integer array of " & (intTotalElement) & " elements is " & vbCrLf & vbCrLf & dblResult & " (" & dblMean & ")"
  596.    
  597.    lbl_Result = strDisplay
  598.  
  599.    'time the function
  600.  
  601.    TimerHandle = cTimerOpen()
  602.    TimerStartOk = cTimerStart(TimerHandle)
  603.    
  604.    For i = 1 To Iteration
  605.       dblResult = cMeanI(Iarray())
  606.    Next i
  607.    
  608.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  609.    
  610.    TimerCloseOk = cTimerClose(TimerHandle)
  611.  
  612. End Sub
  613.  
  614. Private Sub TestReverseSort()
  615.    
  616.    Dim intResult        As Integer
  617.    Dim strDisplay       As String
  618.    
  619.    Dim intLB            As Integer
  620.    Dim intUB            As Integer
  621.    Dim intTotalElement  As Integer
  622.    
  623.    Dim i                As Integer
  624.    
  625.    intResult = False
  626.    strDisplay = ""
  627.    
  628.    ReDim Iarray(arrSize) As Integer
  629.    Randomize Timer
  630.  
  631.    intLB = LBound(Iarray)
  632.    intUB = UBound(Iarray)
  633.    intTotalElement = intUB - intLB + 1
  634.       
  635.    For i = intLB To intUB
  636.       Iarray(i) = RandI * Rnd(1)
  637.       List1.AddItem "" & Iarray(i)
  638.    Next i
  639.  
  640.    intResult = cReverseSortI(Iarray())
  641.  
  642.    For i = intLB To intUB
  643.       List2.AddItem "" & Iarray(i)
  644.    Next i
  645.    
  646.    lbl_Result = strDisplay
  647.  
  648.    'time the function
  649.  
  650.    TimerHandle = cTimerOpen()
  651.    TimerStartOk = cTimerStart(TimerHandle)
  652.    
  653.    For i = 1 To Iteration
  654.       intResult = cReverseSortI(Iarray())
  655.    Next i
  656.    
  657.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  658.    
  659.    TimerCloseOk = cTimerClose(TimerHandle)
  660.  
  661. End Sub
  662.  
  663. Private Sub TestSet()
  664.    
  665.    Dim intResult        As Integer
  666.    Dim strDisplay       As String
  667.    
  668.    Dim intLB            As Integer
  669.    Dim intUB            As Integer
  670.    Dim intTotalElement  As Integer
  671.    
  672.    Dim i                As Integer
  673.    
  674.    intResult = False
  675.    strDisplay = ""
  676.    
  677.    ReDim Iarray(arrSize) As Integer
  678.    Randomize Timer
  679.  
  680.    intLB = LBound(Iarray)
  681.    intUB = UBound(Iarray)
  682.    intTotalElement = intUB - intLB + 1
  683.       
  684.    For i = intLB To intUB
  685.       Iarray(i) = RandI * Rnd(1)
  686.       List1.AddItem "" & Iarray(i)
  687.    Next i
  688.  
  689.    intResult = cSetI(Iarray(), 1024)
  690.  
  691.    For i = intLB To intUB
  692.       List2.AddItem "" & Iarray(i)
  693.    Next i
  694.  
  695.    strDisplay = strDisplay & "Set 1024 to element " & intLB & " of an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
  696.    strDisplay = strDisplay & "Set 1024 to element " & intUB & " of an integer array is : " & Iarray(intUB)
  697.    
  698.    lbl_Result = strDisplay
  699.  
  700.    'time the function
  701.  
  702.    TimerHandle = cTimerOpen()
  703.    TimerStartOk = cTimerStart(TimerHandle)
  704.    
  705.    For i = 1 To Iteration
  706.       intResult = cSetI(Iarray(), 1)
  707.    Next i
  708.    
  709.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  710.    
  711.    TimerCloseOk = cTimerClose(TimerHandle)
  712.  
  713. End Sub
  714.  
  715. Private Sub TestSort()
  716.    
  717.    Dim intResult        As Integer
  718.    Dim strDisplay       As String
  719.    
  720.    Dim intLB            As Integer
  721.    Dim intUB            As Integer
  722.    Dim intTotalElement  As Integer
  723.    
  724.    Dim i                As Integer
  725.    
  726.    intResult = False
  727.    strDisplay = ""
  728.    
  729.    ReDim Iarray(arrSize) As Integer
  730.    Randomize Timer
  731.  
  732.    intLB = LBound(Iarray)
  733.    intUB = UBound(Iarray)
  734.    intTotalElement = intUB - intLB + 1
  735.       
  736.    For i = intLB To intUB
  737.       Iarray(i) = RandI * Rnd(1)
  738.       List1.AddItem "" & Iarray(i)
  739.    Next i
  740.  
  741.    intResult = cSortI(Iarray())
  742.  
  743.    For i = intLB To intUB
  744.       List2.AddItem "" & Iarray(i)
  745.    Next i
  746.    
  747.    lbl_Result = strDisplay
  748.  
  749.    'time the function
  750.  
  751.    TimerHandle = cTimerOpen()
  752.    TimerStartOk = cTimerStart(TimerHandle)
  753.    
  754.    For i = 1 To Iteration
  755.       intResult = cSortI(Iarray())
  756.    Next i
  757.    
  758.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  759.    
  760.    TimerCloseOk = cTimerClose(TimerHandle)
  761.  
  762. End Sub
  763.  
  764. Private Sub TestSum()
  765.   
  766.    Dim dblResult        As Double
  767.    Dim strDisplay       As String
  768.    
  769.    Dim intLB            As Integer
  770.    Dim intUB            As Integer
  771.    Dim intTotalElement  As Integer
  772.    
  773.    Dim i                As Integer
  774.    
  775.    Dim dblSum           As Double
  776.   
  777.    dblResult = 0
  778.    strDisplay = ""
  779.    
  780.    dblSum = 0
  781.    dblSum = 0
  782.    
  783.    ReDim Iarray(arrSize) As Integer
  784.    Randomize Timer
  785.  
  786.    intLB = LBound(Iarray)
  787.    intUB = UBound(Iarray)
  788.    intTotalElement = intUB - intLB + 1
  789.       
  790.    For i = intLB To intUB
  791.       Iarray(i) = Int(RandI * Rnd(1))
  792.       dblSum = dblSum + Iarray(i)
  793.       List1.AddItem "" & Iarray(i)
  794.    Next i
  795.    
  796.    dblResult = cSumI(Iarray())
  797.  
  798.    strDisplay = "The Sum of this integer array of " & (intTotalElement) & " elements is " & vbCrLf & vbCrLf & dblResult & " (" & dblSum & ")"
  799.    
  800.    lbl_Result = strDisplay
  801.  
  802.    'time the function
  803.  
  804.    TimerHandle = cTimerOpen()
  805.    TimerStartOk = cTimerStart(TimerHandle)
  806.    
  807.    For i = 1 To Iteration
  808.       dblResult = cSumI(Iarray())
  809.    Next i
  810.    
  811.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  812.    
  813.    TimerCloseOk = cTimerClose(TimerHandle)
  814.  
  815. End Sub
  816.  
  817. Private Sub TestCount()
  818.    
  819.    Dim intResult        As Integer
  820.    Dim strDisplay       As String
  821.    
  822.    Dim intLB            As Integer
  823.    Dim intUB            As Integer
  824.    Dim intTotalElement  As Integer
  825.    
  826.    Dim i                As Integer
  827.    
  828.    intResult = False
  829.    strDisplay = ""
  830.    
  831.    ReDim Iarray(arrSize) As Integer
  832.    Randomize Timer
  833.  
  834.    intLB = LBound(Iarray)
  835.    intUB = UBound(Iarray)
  836.    intTotalElement = intUB - intLB + 1
  837.       
  838.    For i = intLB To intUB
  839.       Iarray(i) = RandI * Rnd(1)
  840.       List1.AddItem "" & Iarray(i)
  841.    Next i
  842.  
  843.    strDisplay = strDisplay & "Count '" & Iarray(1) & "' is " & cCountI(Iarray(), Iarray(1)) & vbCrLf
  844.    strDisplay = strDisplay & "Count '" & Iarray(3) & "' is " & cCountI(Iarray(), Iarray(3)) & vbCrLf
  845.    strDisplay = strDisplay & "Count '" & Iarray(5) & "' is " & cCountI(Iarray(), Iarray(5)) & vbCrLf
  846.    strDisplay = strDisplay & "Count '" & Iarray(7) & "' is " & cCountI(Iarray(), Iarray(7)) & vbCrLf
  847.    strDisplay = strDisplay & "Count '" & Iarray(9) & "' is " & cCountI(Iarray(), Iarray(9)) & vbCrLf
  848.    strDisplay = strDisplay & "Count '" & -1234 & "' is " & cCountI(Iarray(), -1234)
  849.    
  850.    lbl_Result = strDisplay
  851.  
  852.    'time the function
  853.  
  854.    TimerHandle = cTimerOpen()
  855.    TimerStartOk = cTimerStart(TimerHandle)
  856.    
  857.    For i = 1 To Iteration
  858.       intResult = cCountI(Iarray(), Iarray(intLB))
  859.    Next i
  860.    
  861.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  862.    
  863.    TimerCloseOk = cTimerClose(TimerHandle)
  864.  
  865. End Sub
  866.  
  867. Private Sub TestSearch()
  868.    
  869.    Dim intResult        As Integer
  870.    Dim strDisplay       As String
  871.    
  872.    Dim intLB            As Integer
  873.    Dim intUB            As Integer
  874.    Dim intTotalElement  As Integer
  875.    
  876.    Dim i                As Integer
  877.    
  878.    intResult = False
  879.    strDisplay = ""
  880.    
  881.    ReDim Iarray(arrSize) As Integer
  882.    Randomize Timer
  883.  
  884.    intLB = LBound(Iarray)
  885.    intUB = UBound(Iarray)
  886.    intTotalElement = intUB - intLB + 1
  887.       
  888.    For i = intLB To intUB
  889.       Iarray(i) = RandI * Rnd(1)
  890.       List1.AddItem "" & Iarray(i)
  891.    Next i
  892.  
  893.    strDisplay = strDisplay & "Search '" & Iarray(1) & "' is " & cSearchI(Iarray(), Iarray(1)) & vbCrLf
  894.    strDisplay = strDisplay & "Search '" & Iarray(3) & "' is " & cSearchI(Iarray(), Iarray(3)) & vbCrLf
  895.    strDisplay = strDisplay & "Search '" & Iarray(5) & "' is " & cSearchI(Iarray(), Iarray(5)) & vbCrLf
  896.    strDisplay = strDisplay & "Search '" & Iarray(7) & "' is " & cSearchI(Iarray(), Iarray(7)) & vbCrLf
  897.    strDisplay = strDisplay & "Search '" & Iarray(9) & "' is " & cSearchI(Iarray(), Iarray(9)) & vbCrLf
  898.    strDisplay = strDisplay & "Search '" & -1234 & "' is " & cSearchI(Iarray(), -1234)
  899.    
  900.    lbl_Result = strDisplay
  901.  
  902.    'time the function
  903.  
  904.    TimerHandle = cTimerOpen()
  905.    TimerStartOk = cTimerStart(TimerHandle)
  906.    
  907.    For i = 1 To Iteration
  908.       intResult = cSearchI(Iarray(), Iarray(intLB))
  909.    Next i
  910.    
  911.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  912.    
  913.    TimerCloseOk = cTimerClose(TimerHandle)
  914.  
  915. End Sub
  916.  
  917. Private Sub Command1_Click()
  918.    
  919.    Call cmb_Function_Click
  920.    
  921. End Sub
  922.  
  923. Private Sub TestArrayOnDisk()
  924.    
  925.    Dim intResult        As Integer
  926.    Dim strDisplay       As String
  927.    
  928.    Dim intLB            As Integer
  929.    Dim intUB            As Integer
  930.    Dim intTotalElement  As Integer
  931.    
  932.    Dim i                As Integer
  933.    
  934.    intResult = False
  935.    strDisplay = ""
  936.    
  937.    ReDim Iarray(arrSize) As Integer
  938.    Randomize Timer
  939.  
  940.    intLB = LBound(Iarray)
  941.    intUB = UBound(Iarray)
  942.    intTotalElement = intUB - intLB + 1
  943.       
  944.    For i = intLB To intUB
  945.       Iarray(i) = RandI * Rnd(1)
  946.       List1.AddItem "" & Iarray(i)
  947.    Next i
  948.    
  949.    intResult = cArrayOnDisk("c:\test.dat", Iarray(), PUT_ARRAY_ON_DISK)
  950.    strDisplay = strDisplay & "Save this integer array on disk is '" & intResult & "'" & vbCrLf & vbCrLf
  951.    
  952.    DoEvents
  953.    
  954.    intResult = cSetI(Iarray(), 0)
  955.    strDisplay = strDisplay & "Set all element of this integer to 0 array is '" & intResult & "'" & vbCrLf & vbCrLf
  956.    
  957.    For i = intLB To intUB
  958.       List2.AddItem "" & Iarray(i)
  959.    Next i
  960.    
  961.    DoEvents
  962.    List2.Clear
  963.    
  964.    intResult = cArrayOnDisk("c:\test.dat", Iarray(), GET_ARRAY_ON_DISK)
  965.    strDisplay = strDisplay & "Load from disk to this integer array is '" & intResult & "'"
  966.  
  967.    For i = intLB To intUB
  968.       List2.AddItem "" & Iarray(i)
  969.    Next i
  970.  
  971.    lbl_Result = strDisplay
  972.  
  973.    'time the function
  974.  
  975.    TimerHandle = cTimerOpen()
  976.    TimerStartOk = cTimerStart(TimerHandle)
  977.    
  978.    For i = 1 To Iteration
  979.       intResult = cArrayOnDisk("c:\test.dat", Iarray(), GET_ARRAY_ON_DISK)
  980.    Next i
  981.    
  982.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  983.    
  984.    TimerCloseOk = cTimerClose(TimerHandle)
  985.  
  986. End Sub
  987.  
  988. Private Sub TestMaxNotX()
  989.    
  990.    Dim intResult        As Integer
  991.    Dim strDisplay       As String
  992.    
  993.    Dim intLB            As Integer
  994.    Dim intUB            As Integer
  995.    Dim intTotalElement  As Integer
  996.    
  997.    Dim i                As Integer
  998.    
  999.    intResult = False
  1000.    strDisplay = ""
  1001.    
  1002.    ReDim Iarray(arrSize) As Integer
  1003.    Randomize Timer
  1004.  
  1005.    intLB = LBound(Iarray)
  1006.    intUB = UBound(Iarray)
  1007.    intTotalElement = intUB - intLB + 1
  1008.       
  1009.    For i = intLB To intUB
  1010.       Iarray(i) = RandI * Rnd(1)
  1011.       List1.AddItem "" & Iarray(i)
  1012.    Next i
  1013.  
  1014.    intResult = cSortI(Iarray())
  1015.  
  1016.    For i = intLB To intUB
  1017.       List2.AddItem "" & Iarray(i)
  1018.    Next i
  1019.    
  1020.    intResult = cMaxI(Iarray())
  1021.  
  1022.    strDisplay = strDisplay & "The Max of this integer array is : " & intResult & vbCrLf & vbCrLf
  1023.    
  1024.    strDisplay = strDisplay & "The MaxNotX '" & intResult & "' of this integer array is : " & cMaxNotXI(Iarray(), intResult)
  1025.    
  1026.    lbl_Result = strDisplay
  1027.  
  1028.    'time the function
  1029.  
  1030.    TimerHandle = cTimerOpen()
  1031.    TimerStartOk = cTimerStart(TimerHandle)
  1032.    
  1033.    For i = 1 To Iteration
  1034.       intResult = cMaxNotXI(Iarray(), intResult)
  1035.    Next i
  1036.    
  1037.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1038.    
  1039.    TimerCloseOk = cTimerClose(TimerHandle)
  1040.  
  1041. End Sub
  1042.  
  1043. Public Sub TestMinNotX()
  1044.    
  1045.    Dim intResult        As Integer
  1046.    Dim strDisplay       As String
  1047.    
  1048.    Dim intLB            As Integer
  1049.    Dim intUB            As Integer
  1050.    Dim intTotalElement  As Integer
  1051.    
  1052.    Dim i                As Integer
  1053.    
  1054.    intResult = False
  1055.    strDisplay = ""
  1056.    
  1057.    ReDim Iarray(arrSize) As Integer
  1058.    Randomize Timer
  1059.  
  1060.    intLB = LBound(Iarray)
  1061.    intUB = UBound(Iarray)
  1062.    intTotalElement = intUB - intLB + 1
  1063.       
  1064.    For i = intLB To intUB
  1065.       Iarray(i) = RandI * Rnd(1)
  1066.       List1.AddItem "" & Iarray(i)
  1067.    Next i
  1068.  
  1069.    intResult = cSortI(Iarray())
  1070.  
  1071.    For i = intLB To intUB
  1072.       List2.AddItem "" & Iarray(i)
  1073.    Next i
  1074.    
  1075.    intResult = cMinI(Iarray())
  1076.  
  1077.    strDisplay = strDisplay & "The Min of this integer array is : " & intResult & vbCrLf & vbCrLf
  1078.    
  1079.    strDisplay = strDisplay & "The MinNotX '" & intResult & "' of this integer array is : " & cMinNotXI(Iarray(), intResult)
  1080.    
  1081.    lbl_Result = strDisplay
  1082.  
  1083.    'time the function
  1084.  
  1085.    TimerHandle = cTimerOpen()
  1086.    TimerStartOk = cTimerStart(TimerHandle)
  1087.    
  1088.    For i = 1 To Iteration
  1089.       intResult = cMinNotXI(Iarray(), intResult)
  1090.    Next i
  1091.    
  1092.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1093.    
  1094.    TimerCloseOk = cTimerClose(TimerHandle)
  1095.  
  1096. End Sub
  1097.  
  1098. Private Sub TestSortTypedArray(VarStringSensitivity As Integer, VarStringOrder As Integer)
  1099.    
  1100.    Dim intResult              As Integer
  1101.    Dim strDisplay             As String
  1102.    
  1103.    Dim i                      As Integer
  1104.    
  1105.    Dim TestArray(1 To 10)     As tagTESTARRAY
  1106.    Dim CA                     As tagCONFIGARRAY
  1107.    
  1108.    strDisplay = "SortTypedArray with the following parameters :" & vbCrLf & vbCrLf
  1109.    strDisplay = strDisplay & "   Type'd variable is : " & vbCrLf & vbCrLf
  1110.    strDisplay = strDisplay & "      i1 As Long" & vbCrLf
  1111.    strDisplay = strDisplay & "      i2 As Integer" & vbCrLf
  1112.    strDisplay = strDisplay & "      i3 As String" & vbCrLf & vbCrLf
  1113.    strDisplay = strDisplay & "   Sort order is : " & vbCrLf & vbCrLf
  1114.    strDisplay = strDisplay & "      i1 in descending order" & vbCrLf
  1115.    strDisplay = strDisplay & "      i2 in ascending order" & vbCrLf
  1116.    strDisplay = strDisplay & "      i3 in " & IIf(VarStringOrder = -1, "descending", "ascending") & " order" & vbCrLf & vbCrLf
  1117.    
  1118.    CA.KeyOffset(1) = 0
  1119.    CA.KeyOffset(2) = 4
  1120.    CA.KeyOffset(3) = 8
  1121.    
  1122.    CA.KeyLength(1) = 4
  1123.    CA.KeyLength(2) = 2
  1124.    CA.KeyLength(3) = 0
  1125.    
  1126.    CA.KeyType(1) = STA_LONG
  1127.    CA.KeyType(2) = STA_INTEGER
  1128.    CA.KeyType(3) = VarStringSensitivity
  1129.    
  1130.    CA.KeyOrder(1) = -1
  1131.    CA.KeyOrder(2) = 1
  1132.    CA.KeyOrder(3) = VarStringOrder
  1133.    
  1134.    TestArray(1).i1 = 3
  1135.    TestArray(1).i2 = 1
  1136.    TestArray(1).i3 = "BBB"
  1137.    
  1138.    TestArray(2).i1 = 9
  1139.    TestArray(2).i2 = 7
  1140.    TestArray(2).i3 = "ZZZ"
  1141.    
  1142.    TestArray(3).i1 = 1
  1143.    TestArray(3).i2 = 99
  1144.    TestArray(3).i3 = "ZZZ"
  1145.    
  1146.    TestArray(4).i1 = 1
  1147.    TestArray(4).i2 = -1
  1148.    TestArray(4).i3 = "AAA"
  1149.    
  1150.    TestArray(5).i1 = 1
  1151.    TestArray(5).i2 = -2
  1152.    TestArray(5).i3 = "BBB"
  1153.    
  1154.    TestArray(6).i1 = -1
  1155.    TestArray(6).i2 = 102
  1156.    TestArray(6).i3 = "aaa"
  1157.    
  1158.    TestArray(7).i1 = 3
  1159.    TestArray(7).i2 = 1
  1160.    TestArray(7).i3 = "AAA"
  1161.    
  1162.    TestArray(8).i1 = -1
  1163.    TestArray(8).i2 = 102
  1164.    TestArray(8).i3 = "bbb"
  1165.    
  1166.    TestArray(9).i1 = -1
  1167.    TestArray(9).i2 = 102
  1168.    TestArray(9).i3 = "BBB"
  1169.    
  1170.    TestArray(10).i1 = -1
  1171.    TestArray(10).i2 = 102
  1172.    TestArray(10).i3 = "AAA"
  1173.    
  1174.    For i = 1 To 10
  1175.       List1.AddItem TestArray(i).i1 & vbTab & TestArray(i).i2 & vbTab & TestArray(i).i3
  1176.    Next i
  1177.    
  1178.    intResult = cSortTypedArray(TestArray(), CA)
  1179.    
  1180.    For i = 1 To 10
  1181.       List2.AddItem TestArray(i).i1 & vbTab & TestArray(i).i2 & vbTab & TestArray(i).i3
  1182.    Next i
  1183.    
  1184.    lbl_Result = strDisplay
  1185.  
  1186.    'time the function
  1187.  
  1188.    TimerHandle = cTimerOpen()
  1189.    TimerStartOk = cTimerStart(TimerHandle)
  1190.    
  1191.    For i = 1 To Iteration
  1192.       intResult = cSortTypedArray(TestArray(), CA)
  1193.    Next i
  1194.    
  1195.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1196.    
  1197.    TimerCloseOk = cTimerClose(TimerHandle)
  1198.  
  1199. End Sub
  1200.  
  1201. Private Sub TestSortTypedArray2(VarStringOrder As Integer)
  1202.    
  1203.    Dim intResult              As Integer
  1204.    Dim strDisplay             As String
  1205.    
  1206.    Dim i                      As Integer
  1207.    
  1208.    Dim TestArray(1 To 10)     As tagTESTARRAY
  1209.    Dim CA                     As tagCONFIGARRAY
  1210.    
  1211.    strDisplay = "SortTypedArray with the following parameters :" & vbCrLf & vbCrLf
  1212.    strDisplay = strDisplay & "   Type'd variable is : " & vbCrLf & vbCrLf
  1213.    strDisplay = strDisplay & "      i1 As Long" & vbCrLf
  1214.    strDisplay = strDisplay & "      i2 As Integer" & vbCrLf
  1215.    strDisplay = strDisplay & "      i3 As String" & vbCrLf & vbCrLf
  1216.    strDisplay = strDisplay & "   Sort order is : " & vbCrLf & vbCrLf
  1217.    strDisplay = strDisplay & "      i1 in descending order" & vbCrLf
  1218.    strDisplay = strDisplay & "      i2 in ascending order" & vbCrLf
  1219.    strDisplay = strDisplay & "      i3 in " & IIf(VarStringOrder = -1, "descending", "ascending") & " order (with string as number)" & vbCrLf & vbCrLf
  1220.    
  1221.    CA.KeyOffset(1) = 0
  1222.    CA.KeyOffset(2) = 4
  1223.    CA.KeyOffset(3) = 8
  1224.    
  1225.    CA.KeyLength(1) = 4
  1226.    CA.KeyLength(2) = 2
  1227.    CA.KeyLength(3) = 0
  1228.    
  1229.    CA.KeyType(1) = STA_LONG
  1230.    CA.KeyType(2) = STA_INTEGER
  1231.    CA.KeyType(3) = STA_VARSTRING_NUMBER
  1232.    
  1233.    CA.KeyOrder(1) = -1
  1234.    CA.KeyOrder(2) = 1
  1235.    CA.KeyOrder(3) = VarStringOrder
  1236.    
  1237.    TestArray(1).i1 = 3
  1238.    TestArray(1).i2 = 1
  1239.    TestArray(1).i3 = "11"
  1240.    
  1241.    TestArray(2).i1 = 9
  1242.    TestArray(2).i2 = 7
  1243.    TestArray(2).i3 = "12"
  1244.    
  1245.    TestArray(3).i1 = 1
  1246.    TestArray(3).i2 = 99
  1247.    TestArray(3).i3 = "14"
  1248.    
  1249.    TestArray(4).i1 = 1
  1250.    TestArray(4).i2 = -1
  1251.    TestArray(4).i3 = "2"
  1252.    
  1253.    TestArray(5).i1 = 1
  1254.    TestArray(5).i2 = -2
  1255.    TestArray(5).i3 = "5"
  1256.    
  1257.    TestArray(6).i1 = -1
  1258.    TestArray(6).i2 = 102
  1259.    TestArray(6).i3 = "1"
  1260.    
  1261.    TestArray(7).i1 = 3
  1262.    TestArray(7).i2 = 1
  1263.    TestArray(7).i3 = "111"
  1264.    
  1265.    TestArray(8).i1 = -1
  1266.    TestArray(8).i2 = 102
  1267.    TestArray(8).i3 = "2"
  1268.    
  1269.    TestArray(9).i1 = -1
  1270.    TestArray(9).i2 = 102
  1271.    TestArray(9).i3 = "21"
  1272.    
  1273.    TestArray(10).i1 = -1
  1274.    TestArray(10).i2 = 102
  1275.    TestArray(10).i3 = "11"
  1276.    
  1277.    For i = 1 To 10
  1278.       List1.AddItem TestArray(i).i1 & vbTab & TestArray(i).i2 & vbTab & TestArray(i).i3
  1279.    Next i
  1280.    
  1281.    intResult = cSortTypedArray(TestArray(), CA)
  1282.    
  1283.    For i = 1 To 10
  1284.       List2.AddItem TestArray(i).i1 & vbTab & TestArray(i).i2 & vbTab & TestArray(i).i3
  1285.    Next i
  1286.    
  1287.    lbl_Result = strDisplay
  1288.  
  1289.    'time the function
  1290.  
  1291.    TimerHandle = cTimerOpen()
  1292.    TimerStartOk = cTimerStart(TimerHandle)
  1293.    
  1294.    For i = 1 To Iteration
  1295.       intResult = cSortTypedArray(TestArray(), CA)
  1296.    Next i
  1297.    
  1298.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1299.    
  1300.    TimerCloseOk = cTimerClose(TimerHandle)
  1301.  
  1302. End Sub
  1303.  
  1304. Private Sub TestSortTypedArray3(VarStringSensitivity As Integer, VarStringOrder As Integer)
  1305.    
  1306.    Dim intResult              As Integer
  1307.    Dim strDisplay             As String
  1308.    
  1309.    Dim i                      As Integer
  1310.    
  1311.    Dim TestArray(1 To 10)     As tagTESTVTARRAY
  1312.    Dim CA                     As tagCONFIGARRAY
  1313.    
  1314.    strDisplay = "SortTypedArray with the following parameters :" & vbCrLf & vbCrLf
  1315.    strDisplay = strDisplay & "   Type'd variable is : " & vbCrLf & vbCrLf
  1316.    strDisplay = strDisplay & "      v1 As Variant (Long)" & vbCrLf
  1317.    strDisplay = strDisplay & "      v2 As Variant (Integer)" & vbCrLf
  1318.    strDisplay = strDisplay & "      v3 As Variant (String)" & vbCrLf & vbCrLf
  1319.    strDisplay = strDisplay & "   Sort order is : " & vbCrLf & vbCrLf
  1320.    strDisplay = strDisplay & "      v1 in descending order" & vbCrLf
  1321.    strDisplay = strDisplay & "      v2 in ascending order" & vbCrLf
  1322.    strDisplay = strDisplay & "      v3 in " & IIf(VarStringOrder = -1, "descending", "ascending") & " order" & vbCrLf & vbCrLf
  1323.    
  1324.    CA.KeyOffset(1) = 0
  1325.    CA.KeyOffset(2) = 16
  1326.    CA.KeyOffset(3) = 32
  1327.    
  1328.    CA.KeyLength(1) = 16
  1329.    CA.KeyLength(2) = 16
  1330.    CA.KeyLength(3) = 16
  1331.    
  1332.    CA.KeyType(1) = STA_VT_LONG
  1333.    CA.KeyType(2) = STA_VT_INTEGER
  1334.    CA.KeyType(3) = VarStringSensitivity
  1335.    
  1336.    CA.KeyOrder(1) = -1
  1337.    CA.KeyOrder(2) = 1
  1338.    CA.KeyOrder(3) = VarStringOrder
  1339.    
  1340.    TestArray(1).v1 = 1234567
  1341.    TestArray(1).v2 = 1
  1342.    TestArray(1).v3 = "BBB"
  1343.    
  1344.    TestArray(2).v1 = 9
  1345.    TestArray(2).v2 = 7
  1346.    TestArray(2).v3 = "ZZZ"
  1347.    
  1348.    TestArray(3).v1 = 1
  1349.    TestArray(3).v2 = 99
  1350.    TestArray(3).v3 = "ZZZ"
  1351.    
  1352.    TestArray(4).v1 = 1
  1353.    TestArray(4).v2 = -1
  1354.    TestArray(4).v3 = "AAA"
  1355.    
  1356.    TestArray(5).v1 = 1
  1357.    TestArray(5).v2 = -2
  1358.    TestArray(5).v3 = "BBB"
  1359.    
  1360.    TestArray(6).v1 = -1
  1361.    TestArray(6).v2 = 102
  1362.    TestArray(6).v3 = "aaa"
  1363.    
  1364.    TestArray(7).v1 = 3
  1365.    TestArray(7).v2 = 1
  1366.    TestArray(7).v3 = "AAA"
  1367.    
  1368.    TestArray(8).v1 = -1
  1369.    TestArray(8).v2 = 102
  1370.    TestArray(8).v3 = "bbb"
  1371.    
  1372.    TestArray(9).v1 = -1
  1373.    TestArray(9).v2 = 102
  1374.    TestArray(9).v3 = "BBB"
  1375.    
  1376.    TestArray(10).v1 = -1
  1377.    TestArray(10).v2 = 102
  1378.    TestArray(10).v3 = "AAA"
  1379.    
  1380.    For i = 1 To 10
  1381.       List1.AddItem TestArray(i).v1 & vbTab & TestArray(i).v2 & vbTab & TestArray(i).v3
  1382.    Next i
  1383.    
  1384.    intResult = cSortTypedArray(TestArray(), CA)
  1385.    
  1386.    For i = 1 To 10
  1387.       List2.AddItem TestArray(i).v1 & vbTab & TestArray(i).v2 & vbTab & TestArray(i).v3
  1388.    Next i
  1389.    
  1390.    lbl_Result = strDisplay
  1391.  
  1392.    'time the function
  1393.  
  1394.    TimerHandle = cTimerOpen()
  1395.    TimerStartOk = cTimerStart(TimerHandle)
  1396.    
  1397.    For i = 1 To Iteration
  1398.       intResult = cSortTypedArray(TestArray(), CA)
  1399.    Next i
  1400.    
  1401.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1402.    
  1403.    TimerCloseOk = cTimerClose(TimerHandle)
  1404.  
  1405. End Sub
  1406.  
  1407. Private Sub TestShiftLeft()
  1408.    
  1409.    Dim intResult        As Integer
  1410.    Dim strDisplay       As String
  1411.    
  1412.    Dim intLB            As Integer
  1413.    Dim intUB            As Integer
  1414.    Dim intTotalElement  As Integer
  1415.    
  1416.    Dim i                As Integer
  1417.    
  1418.    intResult = False
  1419.    strDisplay = ""
  1420.    
  1421.    ReDim Iarray(arrSize) As Integer
  1422.    Randomize Timer
  1423.  
  1424.    intLB = LBound(Iarray)
  1425.    intUB = UBound(Iarray)
  1426.    intTotalElement = intUB - intLB + 1
  1427.       
  1428.    For i = intLB To intUB
  1429.       Iarray(i) = RandI * Rnd(1)
  1430.       List1.AddItem "" & Iarray(i)
  1431.    Next i
  1432.  
  1433.    intResult = cShiftLeftI(Iarray(), 32767)
  1434.  
  1435.    For i = intLB To intUB
  1436.       List2.AddItem "" & Iarray(i)
  1437.    Next i
  1438.    
  1439.    strDisplay = strDisplay & "ShiftLeft and set last element to 32767 in an integer array is : " & Iarray(intUB) & vbCrLf & vbCrLf
  1440.    
  1441.    lbl_Result = strDisplay
  1442.  
  1443.    'time the function
  1444.  
  1445.    TimerHandle = cTimerOpen()
  1446.    TimerStartOk = cTimerStart(TimerHandle)
  1447.    
  1448.    For i = 1 To Iteration
  1449.       intResult = cShiftLeftI(Iarray(), 32767)
  1450.    Next i
  1451.    
  1452.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1453.    
  1454.    TimerCloseOk = cTimerClose(TimerHandle)
  1455.  
  1456. End Sub
  1457.  
  1458. Private Sub TestShiftRight()
  1459.    
  1460.    Dim intResult        As Integer
  1461.    Dim strDisplay       As String
  1462.    
  1463.    Dim intLB            As Integer
  1464.    Dim intUB            As Integer
  1465.    Dim intTotalElement  As Integer
  1466.    
  1467.    Dim i                As Integer
  1468.    
  1469.    intResult = False
  1470.    strDisplay = ""
  1471.    
  1472.    ReDim Iarray(arrSize) As Integer
  1473.    Randomize Timer
  1474.  
  1475.    intLB = LBound(Iarray)
  1476.    intUB = UBound(Iarray)
  1477.    intTotalElement = intUB - intLB + 1
  1478.       
  1479.    For i = intLB To intUB
  1480.       Iarray(i) = RandI * Rnd(1)
  1481.       List1.AddItem "" & Iarray(i)
  1482.    Next i
  1483.  
  1484.    intResult = cShiftRightI(Iarray(), 32767)
  1485.  
  1486.    For i = intLB To intUB
  1487.       List2.AddItem "" & Iarray(i)
  1488.    Next i
  1489.    
  1490.    strDisplay = strDisplay & "ShiftRight and set first element to 32767 in an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
  1491.    
  1492.    lbl_Result = strDisplay
  1493.  
  1494.    'time the function
  1495.  
  1496.    TimerHandle = cTimerOpen()
  1497.    TimerStartOk = cTimerStart(TimerHandle)
  1498.    
  1499.    For i = 1 To Iteration
  1500.       intResult = cShiftRightI(Iarray(), 32767)
  1501.    Next i
  1502.    
  1503.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1504.    
  1505.    TimerCloseOk = cTimerClose(TimerHandle)
  1506.  
  1507. End Sub
  1508.  
  1509. Private Sub TestRmvDup()
  1510.    
  1511.    Dim intResult        As Integer
  1512.    Dim strDisplay       As String
  1513.    
  1514.    Dim intLB            As Integer
  1515.    Dim intUB            As Integer
  1516.    Dim intTotalElement  As Integer
  1517.    
  1518.    Dim i                As Integer
  1519.    
  1520.    intResult = False
  1521.    strDisplay = ""
  1522.    
  1523.    ReDim Iarray(arrSize) As Integer
  1524.    Randomize Timer
  1525.  
  1526.    intLB = LBound(Iarray)
  1527.    intUB = UBound(Iarray)
  1528.    intTotalElement = intUB - intLB + 1
  1529.       
  1530.    For i = intLB To intUB
  1531.       Iarray(i) = 3 * Rnd(1)
  1532.       List1.AddItem "" & Iarray(i)
  1533.    Next i
  1534.  
  1535.    intResult = cRmvDupI(Iarray(), False, "", True)
  1536.  
  1537.    intLB = LBound(Iarray)
  1538.    intUB = UBound(Iarray)
  1539.    
  1540.    For i = intLB To intUB
  1541.       List2.AddItem "" & Iarray(i)
  1542.    Next i
  1543.    
  1544.    lbl_Result = strDisplay
  1545.  
  1546.    'time the function
  1547.  
  1548.    TimerHandle = cTimerOpen()
  1549.    TimerStartOk = cTimerStart(TimerHandle)
  1550.    
  1551.    For i = 1 To Iteration
  1552.       intResult = cRmvDupI(Iarray(), False, "", True)
  1553.    Next i
  1554.    
  1555.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1556.    
  1557.    TimerCloseOk = cTimerClose(TimerHandle)
  1558.  
  1559. End Sub
  1560.  
  1561. Private Sub TestSearchStr()
  1562.    
  1563.    Dim intResult        As Integer
  1564.    Dim strDisplay       As String
  1565.    
  1566.    Dim intLB            As Integer
  1567.    Dim intUB            As Integer
  1568.    Dim intTotalElement  As Integer
  1569.    
  1570.    Dim i                As Integer
  1571.    
  1572.    intResult = False
  1573.    strDisplay = ""
  1574.    
  1575.    ReDim Strarray(arrSize) As String
  1576.    Randomize Timer
  1577.  
  1578.    intLB = LBound(Strarray)
  1579.    intUB = UBound(Strarray)
  1580.    intTotalElement = intUB - intLB + 1
  1581.       
  1582.    For i = intLB To intUB - 1
  1583.       Strarray(i) = String$(16, RandI * Rnd(1))
  1584.       List1.AddItem "" & Strarray(i)
  1585.    Next i
  1586.  
  1587.    Strarray(intUB) = "The MCR Company"
  1588.    List1.AddItem "" & Strarray(intUB)
  1589.    
  1590.    strDisplay = strDisplay & "Search '" & Strarray(1) & "' is " & cSearchStr(Strarray(), Strarray(1), False) & vbCrLf
  1591.    strDisplay = strDisplay & "Search '" & Strarray(3) & "' is " & cSearchStr(Strarray(), Strarray(3), False) & vbCrLf
  1592.    strDisplay = strDisplay & "Search '" & Strarray(5) & "' is " & cSearchStr(Strarray(), Strarray(5), False) & vbCrLf
  1593.    strDisplay = strDisplay & "Search '" & Strarray(7) & "' is " & cSearchStr(Strarray(), Strarray(7), False) & vbCrLf
  1594.    strDisplay = strDisplay & "Search '" & Strarray(9) & "' is " & cSearchStr(Strarray(), Strarray(9), False) & vbCrLf & vbCrLf
  1595.    strDisplay = strDisplay & "Search '" & "The MCR Company" & "' with sensitivity is " & cSearchStr(Strarray(), "The MCR Company", True) & vbCrLf
  1596.    strDisplay = strDisplay & "Search '" & "The MCR Company" & "' without sensitivity is " & cSearchStr(Strarray(), "The MCR Company", False) & vbCrLf & vbCrLf
  1597.    strDisplay = strDisplay & "Search '" & "the mcr company" & "' with sensitivity is " & cSearchStr(Strarray(), "the mcr company", True) & vbCrLf
  1598.    strDisplay = strDisplay & "Search '" & "the mcr company" & "' without sensitivity is " & cSearchStr(Strarray(), "the mcr company", False) & vbCrLf
  1599.    
  1600.    lbl_Result = strDisplay
  1601.  
  1602.    'time the function
  1603.  
  1604.    TimerHandle = cTimerOpen()
  1605.    TimerStartOk = cTimerStart(TimerHandle)
  1606.    
  1607.    For i = 1 To Iteration
  1608.       intResult = cSearchStr(Strarray(), Strarray(intLB), False)
  1609.    Next i
  1610.    
  1611.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1612.    
  1613.    TimerCloseOk = cTimerClose(TimerHandle)
  1614.  
  1615. End Sub
  1616.  
  1617. Private Sub TestArrayLookUp()
  1618.    
  1619.    Dim intResult        As Integer
  1620.    Dim strDisplay       As String
  1621.    Dim strResult        As String
  1622.    
  1623.    Dim intLB            As Integer
  1624.    Dim intUB            As Integer
  1625.    Dim intTotalElement  As Integer
  1626.    
  1627.    Dim i                As Integer
  1628.    
  1629.    intResult = False
  1630.    strDisplay = ""
  1631.    
  1632.    ReDim Strarray(arrSize, 1 To 2) As String
  1633.    Randomize Timer
  1634.  
  1635.    intLB = LBound(Strarray, 1)
  1636.    intUB = UBound(Strarray, 1)
  1637.    intTotalElement = intUB - intLB + 1
  1638.       
  1639.    For i = intLB To intUB - 1
  1640.       Strarray(i, 1) = String$(16, RandI * Rnd(1))
  1641.       Strarray(i, 2) = String$(16, RandI * Rnd(1))
  1642.       List1.AddItem "" & Strarray(i, 1) & " = " & Strarray(i, 2)
  1643.    Next i
  1644.  
  1645.    Strarray(intUB, 1) = "Company"
  1646.    Strarray(intUB, 2) = "The MCR Company"
  1647.    List1.AddItem "" & Strarray(intUB, 1) & " = " & Strarray(intUB, 2)
  1648.    
  1649.    strDisplay = strDisplay & "ArrayLookUp '" & Strarray(1, 1) & "' is " & cArrayLookUp(Strarray(), Strarray(1, 1), False) & vbCrLf
  1650.    strDisplay = strDisplay & "ArrayLookUp '" & Strarray(3, 1) & "' is " & cArrayLookUp(Strarray(), Strarray(3, 1), False) & vbCrLf
  1651.    strDisplay = strDisplay & "ArrayLookUp '" & Strarray(5, 1) & "' is " & cArrayLookUp(Strarray(), Strarray(5, 1), False) & vbCrLf
  1652.    strDisplay = strDisplay & "ArrayLookUp '" & Strarray(7, 1) & "' is " & cArrayLookUp(Strarray(), Strarray(7, 1), False) & vbCrLf
  1653.    strDisplay = strDisplay & "ArrayLookUp '" & Strarray(9, 1) & "' is " & cArrayLookUp(Strarray(), Strarray(9, 1), False) & vbCrLf & vbCrLf
  1654.    strDisplay = strDisplay & "ArrayLookUp '" & "Company" & "' with sensitivity is " & cArrayLookUp(Strarray(), "Company", True) & vbCrLf
  1655.    strDisplay = strDisplay & "ArrayLookUp '" & "Company" & "' without sensitivity is " & cArrayLookUp(Strarray(), "Company", False) & vbCrLf & vbCrLf
  1656.    strDisplay = strDisplay & "ArrayLookUp '" & "company" & "' with sensitivity is " & cArrayLookUp(Strarray(), "company", True) & vbCrLf
  1657.    strDisplay = strDisplay & "ArrayLookUp '" & "company" & "' without sensitivity is " & cArrayLookUp(Strarray(), "company", False) & vbCrLf
  1658.    
  1659.    lbl_Result = strDisplay
  1660.  
  1661.    'time the function
  1662.  
  1663.    TimerHandle = cTimerOpen()
  1664.    TimerStartOk = cTimerStart(TimerHandle)
  1665.    
  1666.    For i = 1 To Iteration
  1667.       strResult = cArrayLookUp(Strarray(), Strarray(intLB, 1), False)
  1668.    Next i
  1669.    
  1670.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1671.    
  1672.    TimerCloseOk = cTimerClose(TimerHandle)
  1673.  
  1674. End Sub
  1675.  
  1676.  
  1677.