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