home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmArray
- BorderStyle = 4 'Fixed ToolWindow
- Caption = "Array"
- ClientHeight = 4170
- ClientLeft = 1890
- ClientTop = 3270
- ClientWidth = 6690
- Height = 4575
- Left = 1830
- MaxButton = 0 'False
- MDIChild = -1 'True
- ScaleHeight = 4170
- ScaleWidth = 6690
- ShowInTaskbar = 0 'False
- Top = 2925
- Width = 6810
- Begin VB.ListBox List2
- Height = 2010
- Left = 3510
- TabIndex = 2
- Top = 2070
- Width = 3075
- End
- Begin VB.ListBox List1
- Height = 2010
- Left = 90
- TabIndex = 1
- Top = 2070
- Width = 3075
- End
- Begin Threed.SSPanel SSPanel1
- Align = 1 'Align Top
- Height = 480
- Left = 0
- TabIndex = 3
- Top = 0
- Width = 6690
- _Version = 65536
- _ExtentX = 11800
- _ExtentY = 847
- _StockProps = 15
- ForeColor = -2147483640
- BackColor = 12632256
- Begin VB.ComboBox cmb_Function
- Height = 315
- Left = 1365
- TabIndex = 4
- Top = 90
- Width = 3945
- End
- Begin Threed.SSCommand cmdNP
- Height = 300
- Index = 1
- Left = 6300
- TabIndex = 8
- Top = 90
- Width = 255
- _Version = 65536
- _ExtentX = 450
- _ExtentY = 529
- _StockProps = 78
- Caption = ">"
- BevelWidth = 1
- Font3D = 3
- RoundedCorners = 0 'False
- Outline = 0 'False
- End
- Begin Threed.SSCommand cmdNP
- Height = 300
- Index = 0
- Left = 5460
- TabIndex = 7
- Top = 90
- Width = 255
- _Version = 65536
- _ExtentX = 450
- _ExtentY = 529
- _StockProps = 78
- Caption = "<"
- BevelWidth = 1
- Font3D = 3
- RoundedCorners = 0 'False
- Outline = 0 'False
- End
- Begin VB.Label Label2
- Caption = "&Select a function"
- Height = 255
- Left = 90
- TabIndex = 6
- Top = 120
- Width = 1275
- End
- Begin Threed.SSCommand SSCommand1
- Default = -1 'True
- Height = 300
- Left = 5775
- TabIndex = 5
- Top = 90
- Width = 465
- _Version = 65536
- _ExtentX = 820
- _ExtentY = 529
- _StockProps = 78
- Caption = "&Go"
- BevelWidth = 1
- RoundedCorners = 0 'False
- Outline = 0 'False
- End
- End
- Begin VB.Label lbl_Result
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- ForeColor = &H80000008&
- Height = 1275
- Left = 105
- TabIndex = 0
- Top = 630
- Width = 6495
- End
- Attribute VB_Name = "frmArray"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Option Base 1
- Private Const Iteration = 250
- Private Const arrSize = 10
- Dim IsLoaded As Integer
- Dim TimerStartOk As Integer
- Dim TimerCloseOk As Integer
- Dim TimerHandle As Integer
- Dim TimerValue As Long
- Private Sub TestAdd()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cAddI(array(), 10)
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- strDisplay = strDisplay & "Add 10 to element " & intLB & " of an integer array is : " & array(intLB) & vbCrLf & vbCrLf
- strDisplay = strDisplay & "Add 10 to element " & intUB & " of an integer array is : " & array(intUB)
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cAddI(array(), 1)
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub cmb_Function_Click()
- If (IsLoaded = False) Then Exit Sub
- Call cDisableFI(mdiT2W.Picture1)
- List1.Visible = True
- List2.Visible = True
- List1.Clear
- List2.Clear
- lbl_Result = ""
- DoEvents
- Select Case cmb_Function.ListIndex
- Case 0
- Call TestAdd
- Case 1
- List2.Visible = False
- Call TestCount
- Case 2
- List2.Visible = False
- Call TestDeviation
- Case 3
- Call TestFill
- Case 4
- Call TestFillIncr
- Case 5
- Call TestMax
- Case 6
- List2.Visible = False
- Call TestMean
- Case 7
- Call TestMin
- Case 8
- Call TestReverseSort
- Case 9
- Call TestSearch
- Case 10
- Call TestSet
- Case 11
- Call TestSort
- Case 12
- List2.Visible = False
- Call TestSum
- Case 13
- Call TestArrayOnDisk
- End Select
- DoEvents
- Call cEnableFI(mdiT2W.Picture1)
- End Sub
- Private Sub cmdNP_Click(Index As Integer)
- Call sub_NextPrev(cmb_Function, Index)
- End Sub
- Private Sub Form_Activate()
- mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
- End Sub
- Private Sub Form_Load()
- IsLoaded = False
- Show
- Call sub_Load_Combo(cmb_Function, T2WDirInst + "_array.t2w")
- IsLoaded = True
- End Sub
- Private Sub TestDeviation()
- Dim dblResult As Double
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- Dim dblMean As Double
- Dim dblDeviation As Double
- dblResult = 0
- strDisplay = ""
- dblMean = 0
- dblDeviation = 0
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = Int(RandI * Rnd(1))
- dblMean = dblMean + array(i)
- List1.AddItem "" & array(i)
- Next i
- dblMean = dblMean / (intTotalElement)
- For i = intLB To intUB
- dblDeviation = dblDeviation + ((array(i) - dblMean) * (array(i) - dblMean))
- Next i
- dblDeviation = (Sqr(dblDeviation) / (intTotalElement))
- dblResult = cDeviationI(array())
- strDisplay = "The Deviation of a integer array of " & (intTotalElement) & " elements is " & vbCrLf & vbCrLf & dblResult & " (" & dblDeviation & ")"
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- dblResult = cDeviationI(array())
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestFill()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cFillI(array(), 5)
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- strDisplay = strDisplay & "Fill 1 to element " & intLB & " of an integer array is : " & array(intLB) & vbCrLf & vbCrLf
- strDisplay = strDisplay & "Fill 1 to element " & intUB & " of an integer array is : " & array(intUB)
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cFillI(array(), 1)
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestFillIncr()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cFillIncrI(array(), -2, 3)
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- strDisplay = strDisplay & "Fill -2 by increment 3 to element " & intLB & " of an integer array is : " & array(intLB) & vbCrLf & vbCrLf
- strDisplay = strDisplay & "Fill -2 by increment 3 to element " & intUB & " of an integer array is : " & array(intUB)
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cFillIncrI(array(), -2, 3)
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestMax()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cSortI(array())
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- intResult = cMaxI(array())
- strDisplay = strDisplay & "The Max of this integer array is : " & intResult
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cMaxI(array())
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestMin()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cSortI(array())
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- intResult = cMinI(array())
- strDisplay = strDisplay & "The Min of this integer array is : " & intResult
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cMinI(array())
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestMean()
- Dim dblResult As Double
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- Dim dblMean As Double
- dblResult = 0
- strDisplay = ""
- dblMean = 0
- dblMean = 0
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = Int(RandI * Rnd(1))
- dblMean = dblMean + array(i)
- List1.AddItem "" & array(i)
- Next i
- dblMean = dblMean / (intTotalElement)
- dblResult = cMeanI(array())
- strDisplay = "The Mean of this integer array of " & (intTotalElement) & " elements is " & vbCrLf & vbCrLf & dblResult & " (" & dblMean & ")"
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- dblResult = cMeanI(array())
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestReverseSort()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cReverseSortI(array())
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cReverseSortI(array())
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestSet()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cSetI(array(), 1024)
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- strDisplay = strDisplay & "Set 1024 to element " & intLB & " of an integer array is : " & array(intLB) & vbCrLf & vbCrLf
- strDisplay = strDisplay & "Set 1024 to element " & intUB & " of an integer array is : " & array(intUB)
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cSetI(array(), 1)
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestSort()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cSortI(array())
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cSortI(array())
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestSum()
- Dim dblResult As Double
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- Dim dblSum As Double
- dblResult = 0
- strDisplay = ""
- dblSum = 0
- dblSum = 0
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = Int(RandI * Rnd(1))
- dblSum = dblSum + array(i)
- List1.AddItem "" & array(i)
- Next i
- dblResult = cSumI(array())
- strDisplay = "The Sum of this integer array of " & (intTotalElement) & " elements is " & vbCrLf & vbCrLf & dblResult & " (" & dblSum & ")"
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- dblResult = cSumI(array())
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestCount()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- strDisplay = strDisplay & "Count '" & array(1) & "' is " & cCountI(array(), array(1)) & vbCrLf
- strDisplay = strDisplay & "Count '" & array(3) & "' is " & cCountI(array(), array(3)) & vbCrLf
- strDisplay = strDisplay & "Count '" & array(5) & "' is " & cCountI(array(), array(5)) & vbCrLf
- strDisplay = strDisplay & "Count '" & array(7) & "' is " & cCountI(array(), array(7)) & vbCrLf
- strDisplay = strDisplay & "Count '" & array(9) & "' is " & cCountI(array(), array(9)) & vbCrLf
- strDisplay = strDisplay & "Count '" & -1234 & "' is " & cCountI(array(), -1234)
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cCountI(array(), array(intLB))
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub TestSearch()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- strDisplay = strDisplay & "Search '" & array(1) & "' is " & cSearchI(array(), array(1)) & vbCrLf
- strDisplay = strDisplay & "Search '" & array(3) & "' is " & cSearchI(array(), array(3)) & vbCrLf
- strDisplay = strDisplay & "Search '" & array(5) & "' is " & cSearchI(array(), array(5)) & vbCrLf
- strDisplay = strDisplay & "Search '" & array(7) & "' is " & cSearchI(array(), array(7)) & vbCrLf
- strDisplay = strDisplay & "Search '" & array(9) & "' is " & cSearchI(array(), array(9)) & vbCrLf
- strDisplay = strDisplay & "Search '" & -1234 & "' is " & cSearchI(array(), -1234)
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cSearchI(array(), array(intLB))
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
- Private Sub SSCommand1_Click()
- Call cmb_Function_Click
- End Sub
- Private Sub TestArrayOnDisk()
- Dim intResult As Integer
- Dim strDisplay As String
- Dim intLB As Integer
- Dim intUB As Integer
- Dim intTotalElement As Integer
- Dim i As Integer
- intResult = False
- strDisplay = ""
- ReDim array(arrSize) As Integer
- Randomize Timer
- intLB = LBound(array)
- intUB = UBound(array)
- intTotalElement = intUB - intLB + 1
-
- For i = intLB To intUB
- array(i) = RandI * Rnd(1)
- List1.AddItem "" & array(i)
- Next i
- intResult = cArrayOnDisk("c:\test.dat", array(), PUT_ARRAY_ON_DISK)
- strDisplay = strDisplay & "Save this integer array on disk is '" & intResult & "'" & vbCrLf & vbCrLf
- DoEvents
- intResult = cSetI(array(), 0)
- strDisplay = strDisplay & "Set all element of this integer to 0 array is '" & intResult & "'" & vbCrLf & vbCrLf
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- DoEvents
- List2.Clear
- intResult = cArrayOnDisk("c:\test.dat", array(), GET_ARRAY_ON_DISK)
- strDisplay = strDisplay & "Load from disk to this integer array is '" & intResult & "'"
- For i = intLB To intUB
- List2.AddItem "" & array(i)
- Next i
- lbl_Result = strDisplay
- 'time the function
- TimerHandle = cTimerOpen()
- TimerStartOk = cTimerStart(TimerHandle)
- For i = 1 To Iteration
- intResult = cArrayOnDisk("c:\test.dat", array(), GET_ARRAY_ON_DISK)
- Next i
- mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
- TimerCloseOk = cTimerClose(TimerHandle)
- End Sub
-