home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 11
/
BUGCD1998_02.ISO
/
util
/
time2win
/
t2w32500.exe
/
_ARRAY.FRM
next >
Wrap
Text File
|
1997-12-25
|
41KB
|
1,626 lines
VERSION 5.00
Object = "{0BA686C6-F7D3-101A-993E-0000C0EF6F5E}#1.0#0"; "THREED32.OCX"
Begin VB.Form frmArray
BorderStyle = 4 'Fixed ToolWindow
Caption = "Array"
ClientHeight = 5670
ClientLeft = 1185
ClientTop = 1515
ClientWidth = 7695
MaxButton = 0 'False
MDIChild = -1 'True
PaletteMode = 1 'UseZOrder
ScaleHeight = 5670
ScaleWidth = 7695
ShowInTaskbar = 0 'False
Begin VB.ListBox List2
Height = 2205
Left = 3960
TabIndex = 2
Top = 3360
Width = 3675
End
Begin VB.ListBox List1
Height = 2205
Left = 90
TabIndex = 1
Top = 3360
Width = 3675
End
Begin Threed.SSPanel SSPanel1
Align = 1 'Align Top
Height = 480
Left = 0
TabIndex = 3
Top = 0
Width = 7695
_Version = 65536
_ExtentX = 13573
_ExtentY = 847
_StockProps = 15
ForeColor = -2147483640
BackColor = 12632256
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Begin VB.ComboBox cmb_Function
Height = 315
Left = 1365
TabIndex = 4
Top = 90
Width = 5025
End
Begin Threed.SSCommand cmdNP
Height = 300
Index = 1
Left = 7380
TabIndex = 8
Top = 90
Width = 255
_Version = 65536
_ExtentX = 450
_ExtentY = 529
_StockProps = 78
Caption = ">"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BevelWidth = 1
Font3D = 3
RoundedCorners = 0 'False
Outline = 0 'False
End
Begin Threed.SSCommand cmdNP
Height = 300
Index = 0
Left = 6540
TabIndex = 7
Top = 90
Width = 255
_Version = 65536
_ExtentX = 450
_ExtentY = 529
_StockProps = 78
Caption = "<"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BevelWidth = 1
Font3D = 3
RoundedCorners = 0 'False
Outline = 0 'False
End
Begin Threed.SSCommand SSCommand1
Default = -1 'True
Height = 300
Left = 6855
TabIndex = 5
Top = 90
Width = 465
_Version = 65536
_ExtentX = 820
_ExtentY = 529
_StockProps = 78
Caption = "&Go"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BevelWidth = 1
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
End
Begin VB.Label lbl_Result
Appearance = 0 'Flat
BackColor = &H00C0C0C0&
ForeColor = &H80000008&
Height = 2595
Left = 105
TabIndex = 0
Top = 630
Width = 7575
End
End
Attribute VB_Name = "frmArray"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
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 Type tagTESTARRAY
i1 As Long
i2 As Integer
i3 As String
End Type
Private Type tagTESTVTARRAY
v1 As Variant
v2 As Variant
v3 As Variant
End Type
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cAddI(Iarray(), 10)
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
strDisplay = strDisplay & "Add 10 to element " & intLB & " of an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
strDisplay = strDisplay & "Add 10 to element " & intUB & " of an integer array is : " & Iarray(intUB)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cAddI(Iarray(), 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
Case 14
Call TestMaxNotX
Case 15
Call TestMinNotX
Case 16
Call TestSortTypedArray(STA_VARSTRING_CI, 1) 'case insensitive and ascending
Case 17
Call TestSortTypedArray(STA_VARSTRING_CI, -1) 'case insensitive and descending
Case 18
Call TestSortTypedArray(STA_VARSTRING_CS, 1) 'case sensitive and ascending
Case 19
Call TestSortTypedArray(STA_VARSTRING_CS, -1) 'case sensitive and descending
Case 20
Call TestSortTypedArray2(1) 'string as number
Case 21
Call TestSortTypedArray2(-1) 'string as number
Case 22
Call TestSortTypedArray3(STA_VT_VARSTRING_CI, 1) 'case insensitive and ascending
Case 23
Call TestSortTypedArray3(STA_VT_VARSTRING_CI, -1) 'case insensitive and descending
Case 24
Call TestSortTypedArray3(STA_VT_VARSTRING_CS, 1) 'case sensitive and ascending
Case 25
Call TestSortTypedArray3(STA_VT_VARSTRING_CS, -1) 'case sensitive and descending
Case 26
Call TestShiftLeft
Case 27
Call TestShiftRight
Case 28
Call TestRmvDup
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = Int(RandI * Rnd(1))
dblMean = dblMean + Iarray(i)
List1.AddItem "" & Iarray(i)
Next i
dblMean = dblMean / (intTotalElement)
For i = intLB To intUB
dblDeviation = dblDeviation + ((Iarray(i) - dblMean) * (Iarray(i) - dblMean))
Next i
dblDeviation = (Sqr(dblDeviation) / (intTotalElement))
dblResult = cDeviationI(Iarray())
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(Iarray())
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cFillI(Iarray(), 5)
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
strDisplay = strDisplay & "Fill 1 to element " & intLB & " of an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
strDisplay = strDisplay & "Fill 1 to element " & intUB & " of an integer array is : " & Iarray(intUB)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cFillI(Iarray(), 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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cFillIncrI(Iarray(), -2, 3)
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
strDisplay = strDisplay & "Fill -2 by increment 3 to element " & intLB & " of an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
strDisplay = strDisplay & "Fill -2 by increment 3 to element " & intUB & " of an integer array is : " & Iarray(intUB)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cFillIncrI(Iarray(), -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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cSortI(Iarray())
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
intResult = cMaxI(Iarray())
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(Iarray())
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cSortI(Iarray())
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
intResult = cMinI(Iarray())
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(Iarray())
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = Int(RandI * Rnd(1))
dblMean = dblMean + Iarray(i)
List1.AddItem "" & Iarray(i)
Next i
dblMean = dblMean / (intTotalElement)
dblResult = cMeanI(Iarray())
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(Iarray())
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cReverseSortI(Iarray())
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cReverseSortI(Iarray())
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cSetI(Iarray(), 1024)
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
strDisplay = strDisplay & "Set 1024 to element " & intLB & " of an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
strDisplay = strDisplay & "Set 1024 to element " & intUB & " of an integer array is : " & Iarray(intUB)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cSetI(Iarray(), 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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cSortI(Iarray())
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cSortI(Iarray())
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = Int(RandI * Rnd(1))
dblSum = dblSum + Iarray(i)
List1.AddItem "" & Iarray(i)
Next i
dblResult = cSumI(Iarray())
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(Iarray())
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
strDisplay = strDisplay & "Count '" & Iarray(1) & "' is " & cCountI(Iarray(), Iarray(1)) & vbCrLf
strDisplay = strDisplay & "Count '" & Iarray(3) & "' is " & cCountI(Iarray(), Iarray(3)) & vbCrLf
strDisplay = strDisplay & "Count '" & Iarray(5) & "' is " & cCountI(Iarray(), Iarray(5)) & vbCrLf
strDisplay = strDisplay & "Count '" & Iarray(7) & "' is " & cCountI(Iarray(), Iarray(7)) & vbCrLf
strDisplay = strDisplay & "Count '" & Iarray(9) & "' is " & cCountI(Iarray(), Iarray(9)) & vbCrLf
strDisplay = strDisplay & "Count '" & -1234 & "' is " & cCountI(Iarray(), -1234)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cCountI(Iarray(), Iarray(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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
strDisplay = strDisplay & "Search '" & Iarray(1) & "' is " & cSearchI(Iarray(), Iarray(1)) & vbCrLf
strDisplay = strDisplay & "Search '" & Iarray(3) & "' is " & cSearchI(Iarray(), Iarray(3)) & vbCrLf
strDisplay = strDisplay & "Search '" & Iarray(5) & "' is " & cSearchI(Iarray(), Iarray(5)) & vbCrLf
strDisplay = strDisplay & "Search '" & Iarray(7) & "' is " & cSearchI(Iarray(), Iarray(7)) & vbCrLf
strDisplay = strDisplay & "Search '" & Iarray(9) & "' is " & cSearchI(Iarray(), Iarray(9)) & vbCrLf
strDisplay = strDisplay & "Search '" & -1234 & "' is " & cSearchI(Iarray(), -1234)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cSearchI(Iarray(), Iarray(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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cArrayOnDisk("c:\test.dat", Iarray(), PUT_ARRAY_ON_DISK)
strDisplay = strDisplay & "Save this integer array on disk is '" & intResult & "'" & vbCrLf & vbCrLf
DoEvents
intResult = cSetI(Iarray(), 0)
strDisplay = strDisplay & "Set all element of this integer to 0 array is '" & intResult & "'" & vbCrLf & vbCrLf
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
DoEvents
List2.Clear
intResult = cArrayOnDisk("c:\test.dat", Iarray(), GET_ARRAY_ON_DISK)
strDisplay = strDisplay & "Load from disk to this integer array is '" & intResult & "'"
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cArrayOnDisk("c:\test.dat", Iarray(), GET_ARRAY_ON_DISK)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestMaxNotX()
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cSortI(Iarray())
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
intResult = cMaxI(Iarray())
strDisplay = strDisplay & "The Max of this integer array is : " & intResult & vbCrLf & vbCrLf
strDisplay = strDisplay & "The MaxNotX '" & intResult & "' of this integer array is : " & cMaxNotXI(Iarray(), intResult)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cMaxNotXI(Iarray(), intResult)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Public Sub TestMinNotX()
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cSortI(Iarray())
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
intResult = cMinI(Iarray())
strDisplay = strDisplay & "The Min of this integer array is : " & intResult & vbCrLf & vbCrLf
strDisplay = strDisplay & "The MinNotX '" & intResult & "' of this integer array is : " & cMinNotXI(Iarray(), intResult)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cMinNotXI(Iarray(), intResult)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestSortTypedArray(VarStringSensitivity As Integer, VarStringOrder As Integer)
Dim intResult As Integer
Dim strDisplay As String
Dim i As Integer
Dim TestArray(1 To 10) As tagTESTARRAY
Dim CA As tagCONFIGARRAY
strDisplay = "SortTypedArray with the following parameters :" & vbCrLf & vbCrLf
strDisplay = strDisplay & " Type'd variable is : " & vbCrLf & vbCrLf
strDisplay = strDisplay & " i1 As Long" & vbCrLf
strDisplay = strDisplay & " i2 As Integer" & vbCrLf
strDisplay = strDisplay & " i3 As String" & vbCrLf & vbCrLf
strDisplay = strDisplay & " Sort order is : " & vbCrLf & vbCrLf
strDisplay = strDisplay & " i1 in descending order" & vbCrLf
strDisplay = strDisplay & " i2 in ascending order" & vbCrLf
strDisplay = strDisplay & " i3 in " & IIf(VarStringOrder = -1, "descending", "ascending") & " order" & vbCrLf & vbCrLf
CA.KeyOffset(1) = 0
CA.KeyOffset(2) = 4
CA.KeyOffset(3) = 8
CA.KeyLength(1) = 4
CA.KeyLength(2) = 2
CA.KeyLength(3) = 0
CA.KeyType(1) = STA_LONG
CA.KeyType(2) = STA_INTEGER
CA.KeyType(3) = VarStringSensitivity
CA.KeyOrder(1) = -1
CA.KeyOrder(2) = 1
CA.KeyOrder(3) = VarStringOrder
TestArray(1).i1 = 3
TestArray(1).i2 = 1
TestArray(1).i3 = "BBB"
TestArray(2).i1 = 9
TestArray(2).i2 = 7
TestArray(2).i3 = "ZZZ"
TestArray(3).i1 = 1
TestArray(3).i2 = 99
TestArray(3).i3 = "ZZZ"
TestArray(4).i1 = 1
TestArray(4).i2 = -1
TestArray(4).i3 = "AAA"
TestArray(5).i1 = 1
TestArray(5).i2 = -2
TestArray(5).i3 = "BBB"
TestArray(6).i1 = -1
TestArray(6).i2 = 102
TestArray(6).i3 = "aaa"
TestArray(7).i1 = 3
TestArray(7).i2 = 1
TestArray(7).i3 = "AAA"
TestArray(8).i1 = -1
TestArray(8).i2 = 102
TestArray(8).i3 = "bbb"
TestArray(9).i1 = -1
TestArray(9).i2 = 102
TestArray(9).i3 = "BBB"
TestArray(10).i1 = -1
TestArray(10).i2 = 102
TestArray(10).i3 = "AAA"
For i = 1 To 10
List1.AddItem TestArray(i).i1 & vbTab & TestArray(i).i2 & vbTab & TestArray(i).i3
Next i
intResult = cSortTypedArray(TestArray(), CA)
For i = 1 To 10
List2.AddItem TestArray(i).i1 & vbTab & TestArray(i).i2 & vbTab & TestArray(i).i3
Next i
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cSortTypedArray(TestArray(), CA)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestSortTypedArray2(VarStringOrder As Integer)
Dim intResult As Integer
Dim strDisplay As String
Dim i As Integer
Dim TestArray(1 To 10) As tagTESTARRAY
Dim CA As tagCONFIGARRAY
strDisplay = "SortTypedArray with the following parameters :" & vbCrLf & vbCrLf
strDisplay = strDisplay & " Type'd variable is : " & vbCrLf & vbCrLf
strDisplay = strDisplay & " i1 As Long" & vbCrLf
strDisplay = strDisplay & " i2 As Integer" & vbCrLf
strDisplay = strDisplay & " i3 As String" & vbCrLf & vbCrLf
strDisplay = strDisplay & " Sort order is : " & vbCrLf & vbCrLf
strDisplay = strDisplay & " i1 in descending order" & vbCrLf
strDisplay = strDisplay & " i2 in ascending order" & vbCrLf
strDisplay = strDisplay & " i3 in " & IIf(VarStringOrder = -1, "descending", "ascending") & " order (with string as number)" & vbCrLf & vbCrLf
CA.KeyOffset(1) = 0
CA.KeyOffset(2) = 4
CA.KeyOffset(3) = 8
CA.KeyLength(1) = 4
CA.KeyLength(2) = 2
CA.KeyLength(3) = 0
CA.KeyType(1) = STA_LONG
CA.KeyType(2) = STA_INTEGER
CA.KeyType(3) = STA_VARSTRING_NUMBER
CA.KeyOrder(1) = -1
CA.KeyOrder(2) = 1
CA.KeyOrder(3) = VarStringOrder
TestArray(1).i1 = 3
TestArray(1).i2 = 1
TestArray(1).i3 = "11"
TestArray(2).i1 = 9
TestArray(2).i2 = 7
TestArray(2).i3 = "12"
TestArray(3).i1 = 1
TestArray(3).i2 = 99
TestArray(3).i3 = "14"
TestArray(4).i1 = 1
TestArray(4).i2 = -1
TestArray(4).i3 = "2"
TestArray(5).i1 = 1
TestArray(5).i2 = -2
TestArray(5).i3 = "5"
TestArray(6).i1 = -1
TestArray(6).i2 = 102
TestArray(6).i3 = "1"
TestArray(7).i1 = 3
TestArray(7).i2 = 1
TestArray(7).i3 = "111"
TestArray(8).i1 = -1
TestArray(8).i2 = 102
TestArray(8).i3 = "2"
TestArray(9).i1 = -1
TestArray(9).i2 = 102
TestArray(9).i3 = "21"
TestArray(10).i1 = -1
TestArray(10).i2 = 102
TestArray(10).i3 = "11"
For i = 1 To 10
List1.AddItem TestArray(i).i1 & vbTab & TestArray(i).i2 & vbTab & TestArray(i).i3
Next i
intResult = cSortTypedArray(TestArray(), CA)
For i = 1 To 10
List2.AddItem TestArray(i).i1 & vbTab & TestArray(i).i2 & vbTab & TestArray(i).i3
Next i
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cSortTypedArray(TestArray(), CA)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestSortTypedArray3(VarStringSensitivity As Integer, VarStringOrder As Integer)
Dim intResult As Integer
Dim strDisplay As String
Dim i As Integer
Dim TestArray(1 To 10) As tagTESTVTARRAY
Dim CA As tagCONFIGARRAY
strDisplay = "SortTypedArray with the following parameters :" & vbCrLf & vbCrLf
strDisplay = strDisplay & " Type'd variable is : " & vbCrLf & vbCrLf
strDisplay = strDisplay & " v1 As Variant (Long)" & vbCrLf
strDisplay = strDisplay & " v2 As Variant (Integer)" & vbCrLf
strDisplay = strDisplay & " v3 As Variant (String)" & vbCrLf & vbCrLf
strDisplay = strDisplay & " Sort order is : " & vbCrLf & vbCrLf
strDisplay = strDisplay & " v1 in descending order" & vbCrLf
strDisplay = strDisplay & " v2 in ascending order" & vbCrLf
strDisplay = strDisplay & " v3 in " & IIf(VarStringOrder = -1, "descending", "ascending") & " order" & vbCrLf & vbCrLf
CA.KeyOffset(1) = 0
CA.KeyOffset(2) = 16
CA.KeyOffset(3) = 32
CA.KeyLength(1) = 16
CA.KeyLength(2) = 16
CA.KeyLength(3) = 16
CA.KeyType(1) = STA_VT_LONG
CA.KeyType(2) = STA_VT_INTEGER
CA.KeyType(3) = VarStringSensitivity
CA.KeyOrder(1) = -1
CA.KeyOrder(2) = 1
CA.KeyOrder(3) = VarStringOrder
TestArray(1).v1 = 1234567
TestArray(1).v2 = 1
TestArray(1).v3 = "BBB"
TestArray(2).v1 = 9
TestArray(2).v2 = 7
TestArray(2).v3 = "ZZZ"
TestArray(3).v1 = 1
TestArray(3).v2 = 99
TestArray(3).v3 = "ZZZ"
TestArray(4).v1 = 1
TestArray(4).v2 = -1
TestArray(4).v3 = "AAA"
TestArray(5).v1 = 1
TestArray(5).v2 = -2
TestArray(5).v3 = "BBB"
TestArray(6).v1 = -1
TestArray(6).v2 = 102
TestArray(6).v3 = "aaa"
TestArray(7).v1 = 3
TestArray(7).v2 = 1
TestArray(7).v3 = "AAA"
TestArray(8).v1 = -1
TestArray(8).v2 = 102
TestArray(8).v3 = "bbb"
TestArray(9).v1 = -1
TestArray(9).v2 = 102
TestArray(9).v3 = "BBB"
TestArray(10).v1 = -1
TestArray(10).v2 = 102
TestArray(10).v3 = "AAA"
For i = 1 To 10
List1.AddItem TestArray(i).v1 & vbTab & TestArray(i).v2 & vbTab & TestArray(i).v3
Next i
intResult = cSortTypedArray(TestArray(), CA)
For i = 1 To 10
List2.AddItem TestArray(i).v1 & vbTab & TestArray(i).v2 & vbTab & TestArray(i).v3
Next i
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cSortTypedArray(TestArray(), CA)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestShiftLeft()
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cShiftLeftI(Iarray(), 32767)
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
strDisplay = strDisplay & "ShiftLeft and set last element to 32767 in an integer array is : " & Iarray(intUB) & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cShiftLeftI(Iarray(), 32767)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestShiftRight()
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = RandI * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cShiftRightI(Iarray(), 32767)
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
strDisplay = strDisplay & "ShiftRight and set first element to 32767 in an integer array is : " & Iarray(intLB) & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cShiftRightI(Iarray(), 32767)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestRmvDup()
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 Iarray(arrSize) As Integer
Randomize Timer
intLB = LBound(Iarray)
intUB = UBound(Iarray)
intTotalElement = intUB - intLB + 1
For i = intLB To intUB
Iarray(i) = 3 * Rnd(1)
List1.AddItem "" & Iarray(i)
Next i
intResult = cRmvDupI(Iarray(), False, "", True)
intLB = LBound(Iarray)
intUB = UBound(Iarray)
For i = intLB To intUB
List2.AddItem "" & Iarray(i)
Next i
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cRmvDupI(Iarray(), False, "", True)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub