home *** CD-ROM | disk | FTP | other *** search
/ BUG 11 / BUGCD1998_02.ISO / util / time2win / t2w32500.exe / _ARRAY.FRM next >
Text File  |  1997-12-25  |  41KB  |  1,626 lines

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