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

  1. VERSION 5.00
  2. Begin VB.Form frmBitString 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Bit string"
  5.    ClientHeight    =   4035
  6.    ClientLeft      =   870
  7.    ClientTop       =   2115
  8.    ClientWidth     =   9885
  9.    MaxButton       =   0   'False
  10.    MDIChild        =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   4035
  13.    ScaleWidth      =   9885
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.PictureBox Picture1 
  16.       Align           =   2  'Align Bottom
  17.       BorderStyle     =   0  'None
  18.       Height          =   465
  19.       Left            =   0
  20.       ScaleHeight     =   465
  21.       ScaleWidth      =   9885
  22.       TabIndex        =   4
  23.       Top             =   3570
  24.       Width           =   9885
  25.       Begin VB.CommandButton Command2 
  26.          Caption         =   "&Reset"
  27.          Height          =   285
  28.          Left            =   9000
  29.          TabIndex        =   10
  30.          Top             =   105
  31.          Width           =   825
  32.       End
  33.       Begin VB.TextBox Text1 
  34.          Height          =   285
  35.          Left            =   1440
  36.          TabIndex        =   5
  37.          Tag             =   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  38.          Top             =   90
  39.          Width           =   7485
  40.       End
  41.       Begin VB.Label Label1 
  42.          Caption         =   "&Enter a test string"
  43.          Height          =   255
  44.          Left            =   90
  45.          TabIndex        =   6
  46.          Top             =   120
  47.          Width           =   1275
  48.       End
  49.    End
  50.    Begin VB.Frame Frame1 
  51.       Height          =   570
  52.       Left            =   0
  53.       TabIndex        =   1
  54.       Top             =   -90
  55.       Width           =   9885
  56.       Begin VB.CommandButton cmdNP 
  57.          Caption         =   ">"
  58.          Height          =   285
  59.          Index           =   1
  60.          Left            =   9540
  61.          TabIndex        =   9
  62.          Top             =   195
  63.          Width           =   285
  64.       End
  65.       Begin VB.CommandButton cmdNP 
  66.          Caption         =   "<"
  67.          Height          =   285
  68.          Index           =   0
  69.          Left            =   8640
  70.          TabIndex        =   8
  71.          Top             =   195
  72.          Width           =   285
  73.       End
  74.       Begin VB.CommandButton Command1 
  75.          Caption         =   "&Go"
  76.          Default         =   -1  'True
  77.          Height          =   285
  78.          Left            =   9000
  79.          TabIndex        =   7
  80.          Top             =   195
  81.          Width           =   465
  82.       End
  83.       Begin VB.ComboBox cmb_Function 
  84.          Height          =   315
  85.          Left            =   1365
  86.          TabIndex        =   2
  87.          Top             =   180
  88.          Width           =   7185
  89.       End
  90.       Begin VB.Label Label2 
  91.          Caption         =   "&Select a function"
  92.          Height          =   255
  93.          Left            =   90
  94.          TabIndex        =   3
  95.          Top             =   210
  96.          Width           =   1275
  97.       End
  98.    End
  99.    Begin VB.TextBox txt_Result 
  100.       BackColor       =   &H00C0C0C0&
  101.       BorderStyle     =   0  'None
  102.       Height          =   2895
  103.       Left            =   90
  104.       Locked          =   -1  'True
  105.       MultiLine       =   -1  'True
  106.       ScrollBars      =   2  'Vertical
  107.       TabIndex        =   0
  108.       Top             =   540
  109.       Width           =   9645
  110.    End
  111. End
  112. Attribute VB_Name = "frmBitString"
  113. Attribute VB_GlobalNameSpace = False
  114. Attribute VB_Creatable = False
  115. Attribute VB_PredeclaredId = True
  116. Attribute VB_Exposed = False
  117. Option Explicit
  118. Option Base 1
  119.  
  120. Private Const Iteration = 250
  121.  
  122. Dim IsLoaded         As Integer
  123.  
  124. Dim TimerStartOk     As Integer
  125. Dim TimerCloseOk     As Integer
  126.  
  127. Dim TimerHandle      As Integer
  128. Dim TimerValue       As Long
  129.  
  130. Private Sub cmb_Function_Click()
  131.    
  132.    If (IsLoaded = False) Then Exit Sub
  133.    
  134.    Call cDisableFI(mdiT2W.Picture1)
  135.    
  136.    Picture1.Visible = True
  137.    
  138.    txt_Result = ""
  139.    
  140.    DoEvents
  141.    
  142.    Select Case cmb_Function.ListIndex
  143.       Case 0
  144.          Picture1.Visible = False
  145.          Call TestCreateBits
  146.       Case 1
  147.          Call TestFindBitReset
  148.       Case 2
  149.          Call TestFindBitSet
  150.       Case 3
  151.          Call TestGetBit
  152.       Case 4
  153.          Picture1.Visible = False
  154.          Call TestGiveBitPalindrome
  155.       Case 5
  156.          Call TestIsBitPalindrome
  157.       Case 6
  158.          Call TestReverseAllBits
  159.       Case 7
  160.          Call TestReverseAllBitsByChar
  161.       Case 8
  162.          Call TestSetAllBits
  163.       Case 9
  164.          Call TestSetBit
  165.       Case 10
  166.          Call TestToggleAllBits
  167.       Case 11
  168.          Call TestToggleBit
  169.       Case 12
  170.          Picture1.Visible = False
  171.          Call TestGetBitValue
  172.       Case 13
  173.          Picture1.Visible = False
  174.          Call TestSetBitValue
  175.       Case 14
  176.          Picture1.Visible = False
  177.          Call TestB2I
  178.       Case 15
  179.          Picture1.Visible = False
  180.          Call TestGetBit2Value
  181.       Case 16
  182.          Picture1.Visible = False
  183.          Call TestSetBit2Value
  184.       Case 17
  185.          Picture1.Visible = False
  186.          Call TestB2I
  187.    End Select
  188.  
  189.    DoEvents
  190.    Call cEnableFI(mdiT2W.Picture1)
  191.    
  192. End Sub
  193.  
  194. Private Sub cmdNP_Click(Index As Integer)
  195.  
  196.    Call sub_NextPrev(cmb_Function, Index)
  197.  
  198. End Sub
  199.  
  200. Private Sub Form_Activate()
  201.  
  202.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  203.  
  204. End Sub
  205.  
  206. Private Sub Form_Load()
  207.  
  208.    IsLoaded = False
  209.    
  210.    Show
  211.  
  212.    Text1.Text = Text1.Tag + LCase$(Text1.Tag)
  213.  
  214.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_bitstr.t2w")
  215.    
  216.    IsLoaded = True
  217.    
  218. End Sub
  219.  
  220. Private Sub Command1_Click()
  221.    
  222.    Call cmb_Function_Click
  223.    
  224. End Sub
  225.  
  226.  
  227.  
  228.  
  229. Private Sub TestCreateBits()
  230.    
  231.    Dim intResult        As Integer
  232.    Dim strResult        As String
  233.    Dim strDisplay       As String
  234.    
  235.    Dim i                As Integer
  236.    
  237.    intResult = 0
  238.    
  239.    strResult = ""
  240.    strDisplay = ""
  241.      
  242.    strResult = cCreateBits(1024)
  243.    strDisplay = strDisplay + "Create a bit string for 1024 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  244.    
  245.    strResult = cCreateBits(512)
  246.    strDisplay = strDisplay + "Create a bit string for 512 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  247.  
  248.    strResult = cCreateBits(33)
  249.    strDisplay = strDisplay + "Create a bit string for 33 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  250.  
  251.    strResult = cCreateBits(1)
  252.    strDisplay = strDisplay + "Create a bit string for 1 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  253.  
  254.    strResult = cCreateBits(-1)
  255.    strDisplay = strDisplay + "Create a bit string for -1 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
  256.  
  257.    txt_Result = strDisplay
  258.  
  259.    'time the function
  260.  
  261.    TimerHandle = cTimerOpen()
  262.    TimerStartOk = cTimerStart(TimerHandle)
  263.    
  264.    For i = 1 To Iteration
  265.       strResult = cCreateBits(1024)
  266.    Next i
  267.    
  268.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  269.    
  270.    TimerCloseOk = cTimerClose(TimerHandle)
  271.  
  272. End Sub
  273.  
  274.  
  275.  
  276.  
  277. Private Sub TestFindBitReset()
  278.    
  279.    Dim intResult        As Integer
  280.    Dim strResult        As String
  281.    Dim strDisplay       As String
  282.    
  283.    Dim strData          As String
  284.    
  285.    Dim i                As Integer
  286.    
  287.    intResult = 0
  288.    
  289.    strResult = ""
  290.    strDisplay = ""
  291.      
  292.    strData = Text1.Text
  293.    
  294.    strDisplay = strDisplay + "The following bits are Reset (False) " & vbCrLf & vbCrLf
  295.    
  296.    intResult = True
  297.    
  298.    Do
  299.       intResult = cFindBitReset(strData, intResult)
  300.       If (intResult <> True) Then strDisplay = strDisplay & intResult & ", "
  301.    Loop Until (intResult = True)
  302.    
  303.    strDisplay = Left$(strDisplay, Len(strDisplay) - 1)
  304.    
  305.    strDisplay = strDisplay & vbCrLf & vbCrLf
  306.  
  307.    txt_Result = strDisplay
  308.  
  309.    'time the function
  310.  
  311.    TimerHandle = cTimerOpen()
  312.    TimerStartOk = cTimerStart(TimerHandle)
  313.    
  314.    For i = 1 To Iteration
  315.       intResult = cFindBitReset(strData, i)
  316.    Next i
  317.    
  318.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  319.    
  320.    TimerCloseOk = cTimerClose(TimerHandle)
  321.  
  322. End Sub
  323.  
  324. Private Sub Command2_Click()
  325.    
  326.    Text1.Text = Text1.Tag + LCase$(Text1.Tag)
  327.    
  328.    Call Command1_Click
  329.    
  330. End Sub
  331.  
  332.  
  333.  
  334. Private Sub TestFindBitSet()
  335.    
  336.    Dim intResult        As Integer
  337.    Dim strResult        As String
  338.    Dim strDisplay       As String
  339.    
  340.    Dim strData          As String
  341.    
  342.    Dim i                As Integer
  343.    
  344.    intResult = 0
  345.    
  346.    strResult = ""
  347.    strDisplay = ""
  348.      
  349.    strData = Text1.Text
  350.    
  351.    strDisplay = strDisplay + "The following bits are Set (True) " & vbCrLf & vbCrLf
  352.    
  353.    intResult = True
  354.    
  355.    Do
  356.       intResult = cFindBitSet(strData, intResult)
  357.       If (intResult <> True) Then strDisplay = strDisplay & intResult & ", "
  358.    Loop Until (intResult = True)
  359.    
  360.    strDisplay = Left$(strDisplay, Len(strDisplay) - 1)
  361.    
  362.    strDisplay = strDisplay & vbCrLf & vbCrLf
  363.  
  364.    txt_Result = strDisplay
  365.  
  366.    'time the function
  367.  
  368.    TimerHandle = cTimerOpen()
  369.    TimerStartOk = cTimerStart(TimerHandle)
  370.    
  371.    For i = 1 To Iteration
  372.       intResult = cFindBitSet(strData, i)
  373.    Next i
  374.    
  375.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  376.    
  377.    TimerCloseOk = cTimerClose(TimerHandle)
  378.  
  379. End Sub
  380.  
  381. Private Sub TestGetBit()
  382.    
  383.    Dim intResult        As Integer
  384.    Dim strResult        As String
  385.    Dim strDisplay       As String
  386.    
  387.    Dim strData          As String
  388.    
  389.    Dim i                As Integer
  390.    
  391.    intResult = 0
  392.    
  393.    strResult = ""
  394.    strDisplay = ""
  395.      
  396.    strData = Text1.Text
  397.    
  398.    strDisplay = strDisplay + "Bit '1' is '" & IIf(cGetBit(strData, 1), "set", "reset") & "'" & vbCrLf
  399.    strDisplay = strDisplay + "Bit '3' is '" & IIf(cGetBit(strData, 3), "set", "reset") & "'" & vbCrLf
  400.    strDisplay = strDisplay + "Bit '5' is '" & IIf(cGetBit(strData, 5), "set", "reset") & "'" & vbCrLf
  401.    strDisplay = strDisplay + "Bit '7' is '" & IIf(cGetBit(strData, 7), "set", "reset") & "'" & vbCrLf
  402.    strDisplay = strDisplay + "Bit '100' is '" & IIf(cGetBit(strData, 100), "set", "reset") & "'" & vbCrLf
  403.    strDisplay = strDisplay + "Bit '102' is '" & IIf(cGetBit(strData, 102), "set", "reset") & "'" & vbCrLf
  404.    strDisplay = strDisplay + "Bit '104' is '" & IIf(cGetBit(strData, 104), "set", "reset") & "'" & vbCrLf
  405.    strDisplay = strDisplay + "Bit '106' is '" & IIf(cGetBit(strData, 106), "set", "reset") & "'" & vbCrLf
  406.    
  407.    
  408.    txt_Result = strDisplay
  409.  
  410.    'time the function
  411.  
  412.    TimerHandle = cTimerOpen()
  413.    TimerStartOk = cTimerStart(TimerHandle)
  414.    
  415.    For i = 1 To Iteration
  416.       intResult = cGetBit(strData, i)
  417.    Next i
  418.    
  419.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  420.    
  421.    TimerCloseOk = cTimerClose(TimerHandle)
  422.  
  423. End Sub
  424.  
  425. Private Sub TestGiveBitPalindrome()
  426.    
  427.    Dim intResult        As Integer
  428.    Dim strResult        As String
  429.    Dim strDisplay       As String
  430.    
  431.    Dim strData          As String
  432.    
  433.    Dim i                As Integer
  434.    
  435.    intResult = 0
  436.    
  437.    strResult = ""
  438.    strDisplay = ""
  439.      
  440.    strResult = cGiveBitPalindrome()
  441.    
  442.    strDisplay = strDisplay + "The followings chars are Bit Palindrome : " & vbCrLf & vbCrLf
  443.    strDisplay = strDisplay + "chr(0) and  " & cBlockCharFromRight(cGiveBitPalindrome(), 1)
  444.    
  445.    txt_Result = strDisplay
  446.  
  447.    'time the function
  448.  
  449.    TimerHandle = cTimerOpen()
  450.    TimerStartOk = cTimerStart(TimerHandle)
  451.    
  452.    For i = 1 To Iteration
  453.       strResult = cGiveBitPalindrome()
  454.    Next i
  455.    
  456.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  457.    
  458.    TimerCloseOk = cTimerClose(TimerHandle)
  459.  
  460. End Sub
  461.  
  462. Private Sub TestIsBitPalindrome()
  463.    
  464.    Dim intResult        As Integer
  465.    Dim strResult        As String
  466.    Dim strDisplay       As String
  467.    
  468.    Dim strData          As String
  469.    
  470.    Dim i                As Integer
  471.    
  472.    intResult = 0
  473.    
  474.    strResult = ""
  475.    strDisplay = ""
  476.    
  477.    strData = Text1.Text
  478.      
  479.    intResult = cIsBitPalindrome(strData)
  480.    
  481.    strDisplay = strDisplay + "Test string is " & IIf(intResult, "", "not ") & "Bit Palindrome " & vbCrLf & vbCrLf
  482.    
  483.    strDisplay = strDisplay + "The followings chars are Bit Palindrome : " & vbCrLf
  484.    
  485.    For i = 1 To 255
  486.       If cIsBitPalindrome(Chr$(i)) Then strDisplay = strDisplay + Chr$(i) & " (" & i & ") "
  487.    Next i
  488.  
  489.    txt_Result = strDisplay
  490.  
  491.    'time the function
  492.  
  493.    TimerHandle = cTimerOpen()
  494.    TimerStartOk = cTimerStart(TimerHandle)
  495.    
  496.    For i = 1 To Iteration
  497.       intResult = cIsBitPalindrome(strData)
  498.    Next i
  499.    
  500.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  501.    
  502.    TimerCloseOk = cTimerClose(TimerHandle)
  503.  
  504. End Sub
  505.  
  506. Private Sub TestReverseAllBits()
  507.    
  508.    Dim intResult        As Integer
  509.    Dim strResult        As String
  510.    Dim strDisplay       As String
  511.    
  512.    Dim strData          As String
  513.    
  514.    Dim i                As Integer
  515.    
  516.    intResult = 0
  517.    
  518.    strResult = ""
  519.    strDisplay = ""
  520.    
  521.    strData = Text1.Text
  522.      
  523.    Call cReverseAllBits(strData)
  524.    strDisplay = strDisplay + "Reverse all bits is " & vbCrLf & strData & vbCrLf & vbCrLf
  525.    
  526.    Call cReverseAllBits(strData)
  527.    strDisplay = strDisplay + "Reverse all bits of the reversed is " & vbCrLf & strData & vbCrLf & vbCrLf
  528.    
  529.    txt_Result = strDisplay
  530.  
  531.    'time the function
  532.  
  533.    TimerHandle = cTimerOpen()
  534.    TimerStartOk = cTimerStart(TimerHandle)
  535.    
  536.    For i = 1 To Iteration
  537.       Call cReverseAllBits(strData)
  538.    Next i
  539.    
  540.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  541.    
  542.    TimerCloseOk = cTimerClose(TimerHandle)
  543.  
  544. End Sub
  545.  
  546. Private Sub TestReverseAllBitsByChar()
  547.    
  548.    Dim intResult        As Integer
  549.    Dim strResult        As String
  550.    Dim strDisplay       As String
  551.    
  552.    Dim strData          As String
  553.    
  554.    Dim i                As Integer
  555.    
  556.    intResult = 0
  557.    
  558.    strResult = ""
  559.    strDisplay = ""
  560.    
  561.    strData = Text1.Text
  562.      
  563.    Call cReverseAllBitsByChar(strData)
  564.    strDisplay = strDisplay + "Reverse all bits by char is " & vbCrLf & strData & vbCrLf & vbCrLf
  565.    
  566.    Call cReverseAllBitsByChar(strData)
  567.    strDisplay = strDisplay + "Reverse all bits by char of the reversed is " & vbCrLf & strData & vbCrLf & vbCrLf
  568.    
  569.    txt_Result = strDisplay
  570.  
  571.    'time the function
  572.  
  573.    TimerHandle = cTimerOpen()
  574.    TimerStartOk = cTimerStart(TimerHandle)
  575.    
  576.    For i = 1 To Iteration
  577.       Call cReverseAllBitsByChar(strData)
  578.    Next i
  579.    
  580.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  581.    
  582.    TimerCloseOk = cTimerClose(TimerHandle)
  583.  
  584. End Sub
  585.  
  586. Private Sub TestSetAllBits()
  587.    
  588.    Dim intResult        As Integer
  589.    Dim strResult        As String
  590.    Dim strDisplay       As String
  591.    
  592.    Dim strData          As String
  593.    
  594.    Dim i                As Integer
  595.    
  596.    intResult = 0
  597.    
  598.    strResult = ""
  599.    strDisplay = ""
  600.    
  601.    strData = Text1.Text
  602.    
  603.    Call cSetAllBits(strData, True)
  604.    strDisplay = strDisplay + "Set all bits is " & vbCrLf
  605.    strDisplay = strDisplay + strData & vbCrLf & vbCrLf
  606.    
  607.    Call cSetAllBits(strData, False)
  608.    strDisplay = strDisplay + "Reset all bits is " & vbCrLf
  609.    strDisplay = strDisplay + strData & vbCrLf & vbCrLf
  610.    
  611.    txt_Result = strDisplay
  612.  
  613.    'time the function
  614.  
  615.    TimerHandle = cTimerOpen()
  616.    TimerStartOk = cTimerStart(TimerHandle)
  617.    
  618.    For i = 1 To Iteration
  619.       Call cSetAllBits(strData, True)
  620.    Next i
  621.    
  622.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  623.    
  624.    TimerCloseOk = cTimerClose(TimerHandle)
  625.  
  626. End Sub
  627.  
  628. Private Sub TestSetBit()
  629.    
  630.    Dim intResult        As Integer
  631.    Dim strResult        As String
  632.    Dim strDisplay       As String
  633.    
  634.    Dim strData          As String
  635.    
  636.    Dim i                As Integer
  637.    
  638.    intResult = 0
  639.    
  640.    strResult = ""
  641.    strDisplay = ""
  642.    
  643.    strData = Text1.Text
  644.    
  645.    Call cSetBit(strData, 0, True)
  646.    strDisplay = strDisplay + "Set bit '0' is '" & strData & "'" & vbCrLf
  647.    Call cSetBit(strData, 5, True)
  648.    strDisplay = strDisplay + "Set bit '5' is '" & strData & "'" & vbCrLf
  649.    Call cSetBit(strData, 7, True)
  650.    strDisplay = strDisplay + "Set bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
  651.    
  652.    Call cSetBit(strData, 0, False)
  653.    strDisplay = strDisplay + "Reset bit '0' is '" & strData & "'" & vbCrLf
  654.    Call cSetBit(strData, 5, False)
  655.    strDisplay = strDisplay + "Reset bit '5' is '" & strData & "'" & vbCrLf
  656.    Call cSetBit(strData, 7, False)
  657.    strDisplay = strDisplay + "Reset bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
  658.    
  659.    Call cSetBit(strData, 22, True)
  660.    strDisplay = strDisplay + "Set bit '22' is '" & strData & "'" & vbCrLf
  661.    Call cSetBit(strData, 30, True)
  662.    strDisplay = strDisplay + "Set bit '30' is '" & strData & "'" & vbCrLf
  663.    Call cSetBit(strData, 38, True)
  664.    strDisplay = strDisplay + "Set bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
  665.    
  666.    Call cSetBit(strData, 22, False)
  667.    strDisplay = strDisplay + "Reset bit '22' is '" & strData & "'" & vbCrLf
  668.    Call cSetBit(strData, 30, False)
  669.    strDisplay = strDisplay + "Reset bit '30' is '" & strData & "'" & vbCrLf
  670.    Call cSetBit(strData, 38, False)
  671.    strDisplay = strDisplay + "Reset bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
  672.    
  673.    txt_Result = strDisplay
  674.  
  675.    'time the function
  676.  
  677.    TimerHandle = cTimerOpen()
  678.    TimerStartOk = cTimerStart(TimerHandle)
  679.    
  680.    For i = 1 To Iteration
  681.       Call cSetBit(strData, 0, True)
  682.    Next i
  683.    
  684.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  685.    
  686.    TimerCloseOk = cTimerClose(TimerHandle)
  687.  
  688. End Sub
  689.  
  690. Private Sub TestToggleAllBits()
  691.    
  692.    Dim intResult        As Integer
  693.    Dim strResult        As String
  694.    Dim strDisplay       As String
  695.    
  696.    Dim strData          As String
  697.    
  698.    Dim i                As Integer
  699.    
  700.    intResult = 0
  701.    
  702.    strResult = ""
  703.    strDisplay = ""
  704.    
  705.    strData = Text1.Text
  706.    
  707.    Call cToggleAllBits(strData)
  708.    strDisplay = strDisplay + "Toggle all bits is " & vbCrLf
  709.    strDisplay = strDisplay + strData & vbCrLf & vbCrLf
  710.    
  711.    Call cToggleAllBits(strData)
  712.    strDisplay = strDisplay + "Toggle all bits of the toggled is " & vbCrLf
  713.    strDisplay = strDisplay + strData & vbCrLf & vbCrLf
  714.    
  715.    txt_Result = strDisplay
  716.  
  717.    'time the function
  718.  
  719.    TimerHandle = cTimerOpen()
  720.    TimerStartOk = cTimerStart(TimerHandle)
  721.    
  722.    For i = 1 To Iteration
  723.       Call cToggleAllBits(strData)
  724.    Next i
  725.    
  726.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  727.    
  728.    TimerCloseOk = cTimerClose(TimerHandle)
  729.  
  730. End Sub
  731.  
  732. Private Sub TestToggleBit()
  733.    
  734.    Dim intResult        As Integer
  735.    Dim strResult        As String
  736.    Dim strDisplay       As String
  737.    
  738.    Dim strData          As String
  739.    
  740.    Dim i                As Integer
  741.    
  742.    intResult = 0
  743.    
  744.    strResult = ""
  745.    strDisplay = ""
  746.    
  747.    strData = Text1.Text
  748.    
  749.    Call cToggleBit(strData, 0)
  750.    strDisplay = strDisplay + "Toggle bit '0' is '" & strData & "'" & vbCrLf
  751.    Call cToggleBit(strData, 5)
  752.    strDisplay = strDisplay + "Toggle bit '5' is '" & strData & "'" & vbCrLf
  753.    Call cToggleBit(strData, 7)
  754.    strDisplay = strDisplay + "Toggle bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
  755.    
  756.    Call cToggleBit(strData, 0)
  757.    strDisplay = strDisplay + "Toggle bit '0' is '" & strData & "'" & vbCrLf
  758.    Call cToggleBit(strData, 5)
  759.    strDisplay = strDisplay + "Toggle bit '5' is '" & strData & "'" & vbCrLf
  760.    Call cToggleBit(strData, 7)
  761.    strDisplay = strDisplay + "Toggle bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
  762.    
  763.    Call cToggleBit(strData, 22)
  764.    strDisplay = strDisplay + "Toggle bit '22' is '" & strData & "'" & vbCrLf
  765.    Call cToggleBit(strData, 30)
  766.    strDisplay = strDisplay + "Toggle bit '30' is '" & strData & "'" & vbCrLf
  767.    Call cToggleBit(strData, 38)
  768.    strDisplay = strDisplay + "Toggle bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
  769.    
  770.    Call cToggleBit(strData, 22)
  771.    strDisplay = strDisplay + "Toggle bit '22' is '" & strData & "'" & vbCrLf
  772.    Call cToggleBit(strData, 30)
  773.    strDisplay = strDisplay + "Toggle bit '30' is '" & strData & "'" & vbCrLf
  774.    Call cToggleBit(strData, 38)
  775.    strDisplay = strDisplay + "Toggle bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
  776.    
  777.    txt_Result = strDisplay
  778.  
  779.    'time the function
  780.  
  781.    TimerHandle = cTimerOpen()
  782.    TimerStartOk = cTimerStart(TimerHandle)
  783.    
  784.    For i = 1 To Iteration
  785.       Call cToggleBit(strData, 0)
  786.    Next i
  787.    
  788.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  789.    
  790.    TimerCloseOk = cTimerClose(TimerHandle)
  791.  
  792. End Sub
  793.  
  794. Private Sub TestGetBitValue()
  795.    
  796.    Dim intResult        As Integer
  797.    Dim strResult        As String
  798.    Dim strDisplay       As String
  799.    
  800.    Dim bData            As Byte
  801.    Dim iData            As Integer
  802.    Dim lData            As Long
  803.    Dim sData            As Single
  804.    Dim dData            As Double
  805.    
  806.    Dim i                As Integer
  807.    
  808.    intResult = 0
  809.    
  810.    strResult = ""
  811.    strDisplay = ""
  812.    
  813.    Call cRndInit(-1)
  814.    
  815.    bData = (Abs(cRndI()) Mod 256)
  816.    iData = Abs(cRndI())
  817.    lData = Abs(cRndL())
  818.    sData = Abs(cRndS())
  819.    dData = Abs(cRndD())
  820.      
  821.    strDisplay = strDisplay + "Byte value : " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf
  822.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitB(bData, 0), "set", "reset") & vbCrLf
  823.    strDisplay = strDisplay + "   bit 1 is " & IIf(cGetBitB(bData, 1), "set", "reset") & vbCrLf
  824.    strDisplay = strDisplay + "   bit 3 is " & IIf(cGetBitB(bData, 3), "set", "reset") & vbCrLf
  825.    strDisplay = strDisplay + "   bit 5 is " & IIf(cGetBitB(bData, 5), "set", "reset") & vbCrLf
  826.    strDisplay = strDisplay + "   bit 7 is " & IIf(cGetBitB(bData, 7), "set", "reset") & vbCrLf & vbCrLf
  827.    
  828.    strDisplay = strDisplay + "Integer value : " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  829.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitI(iData, 0), "set", "reset") & vbCrLf
  830.    strDisplay = strDisplay + "   bit 3 is " & IIf(cGetBitI(iData, 3), "set", "reset") & vbCrLf
  831.    strDisplay = strDisplay + "   bit 7 is " & IIf(cGetBitI(iData, 7), "set", "reset") & vbCrLf
  832.    strDisplay = strDisplay + "   bit 11 is " & IIf(cGetBitI(iData, 11), "set", "reset") & vbCrLf
  833.    strDisplay = strDisplay + "   bit 15 is " & IIf(cGetBitI(iData, 15), "set", "reset") & vbCrLf & vbCrLf
  834.    
  835.    strDisplay = strDisplay + "Long value : " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  836.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitL(lData, 0), "set", "reset") & vbCrLf
  837.    strDisplay = strDisplay + "   bit 5 is " & IIf(cGetBitL(lData, 5), "set", "reset") & vbCrLf
  838.    strDisplay = strDisplay + "   bit 10 is " & IIf(cGetBitL(lData, 10), "set", "reset") & vbCrLf
  839.    strDisplay = strDisplay + "   bit 15 is " & IIf(cGetBitL(lData, 15), "set", "reset") & vbCrLf
  840.    strDisplay = strDisplay + "   bit 20 is " & IIf(cGetBitL(lData, 20), "set", "reset") & vbCrLf & vbCrLf
  841.    
  842.    strDisplay = strDisplay + "Single value : " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  843.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitS(sData, 0), "set", "reset") & vbCrLf
  844.    strDisplay = strDisplay + "   bit 5 is " & IIf(cGetBitS(sData, 5), "set", "reset") & vbCrLf
  845.    strDisplay = strDisplay + "   bit 10 is " & IIf(cGetBitS(sData, 10), "set", "reset") & vbCrLf
  846.    strDisplay = strDisplay + "   bit 15 is " & IIf(cGetBitS(sData, 15), "set", "reset") & vbCrLf
  847.    strDisplay = strDisplay + "   bit 20 is " & IIf(cGetBitS(sData, 20), "set", "reset") & vbCrLf & vbCrLf
  848.    
  849.    strDisplay = strDisplay + "Double value : " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  850.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitD(dData, 0), "set", "reset") & vbCrLf
  851.    strDisplay = strDisplay + "   bit 10 is " & IIf(cGetBitD(dData, 10), "set", "reset") & vbCrLf
  852.    strDisplay = strDisplay + "   bit 20 is " & IIf(cGetBitD(dData, 20), "set", "reset") & vbCrLf
  853.    strDisplay = strDisplay + "   bit 30 is " & IIf(cGetBitD(dData, 30), "set", "reset") & vbCrLf
  854.    strDisplay = strDisplay + "   bit 40 is " & IIf(cGetBitD(dData, 40), "set", "reset") & vbCrLf & vbCrLf
  855.    
  856.    txt_Result = strDisplay
  857.  
  858.    'time the function
  859.  
  860.    TimerHandle = cTimerOpen()
  861.    TimerStartOk = cTimerStart(TimerHandle)
  862.    
  863.    For i = 1 To Iteration
  864.       intResult = cGetBitI(iData, i)
  865.    Next i
  866.    
  867.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  868.    
  869.    TimerCloseOk = cTimerClose(TimerHandle)
  870.  
  871. End Sub
  872. Private Sub TestGetBit2Value()
  873.    
  874.    Dim intResult        As Integer
  875.    Dim strResult        As String
  876.    Dim strDisplay       As String
  877.    
  878.    Dim iData            As Integer
  879.    Dim lData            As Long
  880.    
  881.    Dim i                As Integer
  882.    
  883.    intResult = 0
  884.    
  885.    strResult = ""
  886.    strDisplay = ""
  887.    
  888.    Call cRndInit(-1)
  889.    
  890.    iData = Abs(cRndI())
  891.    lData = Abs(cRndL())
  892.      
  893.    strDisplay = strDisplay + "Integer value : " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  894.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitI2(iData, 0), "set", "reset") & vbCrLf
  895.    strDisplay = strDisplay + "   bit 3 is " & IIf(cGetBitI2(iData, 3), "set", "reset") & vbCrLf
  896.    strDisplay = strDisplay + "   bit 7 is " & IIf(cGetBitI2(iData, 7), "set", "reset") & vbCrLf
  897.    strDisplay = strDisplay + "   bit 11 is " & IIf(cGetBitI2(iData, 11), "set", "reset") & vbCrLf
  898.    strDisplay = strDisplay + "   bit 15 is " & IIf(cGetBitI2(iData, 15), "set", "reset") & vbCrLf & vbCrLf
  899.    
  900.    strDisplay = strDisplay + "Long value : " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  901.    strDisplay = strDisplay + "   bit 0 is " & IIf(cGetBitL2(lData, 0), "set", "reset") & vbCrLf
  902.    strDisplay = strDisplay + "   bit 5 is " & IIf(cGetBitL2(lData, 5), "set", "reset") & vbCrLf
  903.    strDisplay = strDisplay + "   bit 10 is " & IIf(cGetBitL2(lData, 10), "set", "reset") & vbCrLf
  904.    strDisplay = strDisplay + "   bit 15 is " & IIf(cGetBitL2(lData, 15), "set", "reset") & vbCrLf
  905.    strDisplay = strDisplay + "   bit 20 is " & IIf(cGetBitL2(lData, 20), "set", "reset") & vbCrLf & vbCrLf
  906.    
  907.    txt_Result = strDisplay
  908.  
  909.    'time the function
  910.  
  911.    TimerHandle = cTimerOpen()
  912.    TimerStartOk = cTimerStart(TimerHandle)
  913.    
  914.    For i = 1 To Iteration
  915.       intResult = cGetBitI2(iData, i)
  916.    Next i
  917.    
  918.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  919.    
  920.    TimerCloseOk = cTimerClose(TimerHandle)
  921.  
  922. End Sub
  923.  
  924. Private Sub TestSetBitValue()
  925.    
  926.    Dim intResult        As Integer
  927.    Dim strResult        As String
  928.    Dim strDisplay       As String
  929.    
  930.    Dim bData            As Byte
  931.    Dim iData            As Integer
  932.    Dim lData            As Long
  933.    Dim sData            As Single
  934.    Dim dData            As Double
  935.    
  936.    Dim i                As Integer
  937.    
  938.    intResult = 0
  939.    
  940.    strResult = ""
  941.    strDisplay = ""
  942.    
  943.    bData = (Abs(cRndI()) Mod 256)
  944.    iData = Abs(cRndI())
  945.    lData = Abs(cRndL())
  946.    sData = Abs(cRndS())
  947.    dData = Abs(cRndD())
  948.      
  949.    strDisplay = strDisplay + "Byte value : " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf
  950.    Call cSetBitB(bData, 0, True)
  951.    strDisplay = strDisplay + "   set bit 0 is " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf
  952.    Call cSetBitB(bData, 3, False)
  953.    strDisplay = strDisplay + "   reset bit 3 is " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf
  954.    Call cSetBitB(bData, 5, True)
  955.    strDisplay = strDisplay + "   set bit 5 is " & bData & " (" & cToBinary(cMKB(bData)) & ")" & vbCrLf & vbCrLf
  956.    
  957.    strDisplay = strDisplay + "Integer value : " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  958.    Call cSetBitI(iData, 3, True)
  959.    strDisplay = strDisplay + "   set bit 3 is " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  960.    Call cSetBitI(iData, 6, False)
  961.    strDisplay = strDisplay + "   reset bit 6 is " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf
  962.    Call cSetBitI(iData, 9, True)
  963.    strDisplay = strDisplay + "   set bit 9 is " & iData & " (" & cToBinary(cMKI(iData)) & ")" & vbCrLf & vbCrLf
  964.    
  965.    strDisplay = strDisplay + "Long value : " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  966.    Call cSetBitL(lData, 6, True)
  967.    strDisplay = strDisplay + "   set bit 6 is " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  968.    Call cSetBitL(lData, 12, False)
  969.    strDisplay = strDisplay + "   reset bit 12 is " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf
  970.    Call cSetBitL(lData, 24, True)
  971.    strDisplay = strDisplay + "   set bit 24 is " & lData & " (" & cToBinary(cMKL(lData)) & ")" & vbCrLf & vbCrLf
  972.    
  973.    strDisplay = strDisplay + "Single value : " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  974.    Call cSetBitS(sData, 0, True)
  975.    strDisplay = strDisplay + "   set bit 0 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  976.    Call cSetBitS(sData, 3, True)
  977.    strDisplay = strDisplay + "   set bit 3 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  978.    Call cSetBitS(sData, 6, True)
  979.    strDisplay = strDisplay + "   set bit 6 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  980.    Call cSetBitS(sData, 12, True)
  981.    strDisplay = strDisplay + "   set bit 12 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf
  982.    Call cSetBitS(sData, 24, True)
  983.    strDisplay = strDisplay + "   set bit 24 is " & sData & " (" & cToBinary(cMKS(sData)) & ")" & vbCrLf & vbCrLf
  984.    
  985.    strDisplay = strDisplay + "Double value : " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  986.    Call cSetBitD(dData, 0, False)
  987.    strDisplay = strDisplay + "   reset bit 0 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  988.    Call cSetBitD(dData, 3, False)
  989.    strDisplay = strDisplay + "   reset bit 3 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  990.    Call cSetBitD(dData, 12, False)
  991.    strDisplay = strDisplay + "   reset bit 12 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  992.    Call cSetBitD(dData, 24, False)
  993.    strDisplay = strDisplay + "   reset bit 24 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf
  994.    Call cSetBitD(dData, 48, False)
  995.    strDisplay = strDisplay + "   reset bit 48 is " & dData & " (" & cToBinary(cMKD(dData)) & ")" & vbCrLf & vbCrLf
  996.    
  997.    txt_Result = strDisplay
  998.  
  999.    'time the function
  1000.  
  1001.    TimerHandle = cTimerOpen()
  1002.    TimerStartOk = cTimerStart(TimerHandle)
  1003.    
  1004.    For i = 1 To Iteration
  1005.       Call cSetBitI(iData, 0, True)
  1006.    Next i
  1007.    
  1008.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1009.    
  1010.    TimerCloseOk = cTimerClose(TimerHandle)
  1011.  
  1012. End Sub
  1013.  
  1014. Private Sub TestSetBit2Value()
  1015.    
  1016.    Dim intResult        As Integer
  1017.    Dim strResult        As String
  1018.    Dim strDisplay       As String
  1019.    
  1020.    Dim iData            As Integer
  1021.    Dim lData            As Long
  1022.    
  1023.    Dim i                As Integer
  1024.    
  1025.    intResult = 0
  1026.    
  1027.    strResult = ""
  1028.    strDisplay = ""
  1029.    
  1030.    iData = Abs(cRndI())
  1031.    lData = Abs(cRndL())
  1032.      
  1033.    strDisplay = strDisplay + "Integer value : " & iData & " (" & cI2B(iData) & ")" & vbCrLf
  1034.    Call cSetBitI2(iData, 3, True)
  1035.    strDisplay = strDisplay + "   set bit 3 is " & iData & " (" & cI2B(iData) & ")" & vbCrLf
  1036.    Call cSetBitI2(iData, 6, False)
  1037.    strDisplay = strDisplay + "   reset bit 6 is " & iData & " (" & cI2B(iData) & ")" & vbCrLf
  1038.    Call cSetBitI2(iData, 9, True)
  1039.    strDisplay = strDisplay + "   set bit 9 is " & iData & " (" & cI2B(iData) & ")" & vbCrLf & vbCrLf
  1040.    
  1041.    strDisplay = strDisplay + "Long value : " & lData & " (" & cL2B(lData) & ")" & vbCrLf
  1042.    Call cSetBitL2(lData, 6, True)
  1043.    strDisplay = strDisplay + "   set bit 6 is " & lData & " (" & cL2B(lData) & ")" & vbCrLf
  1044.    Call cSetBitL2(lData, 12, False)
  1045.    strDisplay = strDisplay + "   reset bit 12 is " & lData & " (" & cL2B(lData) & ")" & vbCrLf
  1046.    Call cSetBitL2(lData, 24, True)
  1047.    strDisplay = strDisplay + "   set bit 24 is " & lData & " (" & cL2B(lData) & ")" & vbCrLf & vbCrLf
  1048.    
  1049.    txt_Result = strDisplay
  1050.  
  1051.    'time the function
  1052.  
  1053.    TimerHandle = cTimerOpen()
  1054.    TimerStartOk = cTimerStart(TimerHandle)
  1055.    
  1056.    For i = 1 To Iteration
  1057.       Call cSetBitI2(iData, 0, True)
  1058.    Next i
  1059.    
  1060.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1061.    
  1062.    TimerCloseOk = cTimerClose(TimerHandle)
  1063.  
  1064. End Sub
  1065.  
  1066. Private Sub TestB2I()
  1067.    
  1068.    Dim lResult          As Long
  1069.    Dim strResult        As String
  1070.    Dim strDisplay       As String
  1071.    
  1072.    Dim i                As Integer
  1073.    
  1074.    Dim i1               As String
  1075.    Dim i2               As String
  1076.    Dim l1               As String
  1077.    Dim l2               As String
  1078.    
  1079.    i1 = "1010101010101010"
  1080.    i2 = "0101010101010101"
  1081.    
  1082.    l1 = "10101010101010101010101010101010"
  1083.    l2 = "01010101010101010101010101010101"
  1084.    
  1085.    lResult = 0
  1086.    
  1087.    strResult = ""
  1088.    strDisplay = ""
  1089.      
  1090.    strDisplay = strDisplay & "B2I of " & i1 & " is " & cB2I(i1) & vbCrLf
  1091.    strDisplay = strDisplay & "B2I of " & i2 & " is " & cB2I(i2) & vbCrLf & vbCrLf
  1092.    
  1093.    strDisplay = strDisplay & "I2B of " & cB2I(i1) & " is " & cI2B(cB2I(i1)) & vbCrLf
  1094.    strDisplay = strDisplay & "I2B of " & cB2I(i2) & " is " & cI2B(cB2I(i2)) & vbCrLf & vbCrLf
  1095.    
  1096.    strDisplay = strDisplay & "I2Bext (bin = x0) of " & cB2I(i1) & " is " & cI2Bext(cB2I(i1), "x0") & vbCrLf
  1097.    strDisplay = strDisplay & "I2Bext (bin = x0) of " & cB2I(i2) & " is " & cI2Bext(cB2I(i2), "x0") & vbCrLf & vbCrLf
  1098.    
  1099.    strDisplay = strDisplay & "B2L of " & l1 & " is " & cB2L(l1) & vbCrLf
  1100.    strDisplay = strDisplay & "B2L of " & l2 & " is " & cB2L(l2) & vbCrLf & vbCrLf
  1101.    
  1102.    strDisplay = strDisplay & "L2B of " & cB2L(l1) & " is " & cL2B(cB2L(l1)) & vbCrLf
  1103.    strDisplay = strDisplay & "L2B of " & cB2L(l2) & " is " & cL2B(cB2L(l2)) & vbCrLf & vbCrLf
  1104.    
  1105.    strDisplay = strDisplay & "L2Bext (bin = x0) of " & cB2L(l1) & " is " & cL2Bext(cB2L(l1), "x0") & vbCrLf
  1106.    strDisplay = strDisplay & "L2Bext (bin = x0) of " & cB2L(l2) & " is " & cL2Bext(cB2L(l2), "x0") & vbCrLf & vbCrLf
  1107.    
  1108.    txt_Result = strDisplay
  1109.  
  1110.    'time the function
  1111.  
  1112.    TimerHandle = cTimerOpen()
  1113.    TimerStartOk = cTimerStart(TimerHandle)
  1114.    
  1115.    For i = 1 To Iteration
  1116.       strResult = cB2I(12345)
  1117.    Next i
  1118.    
  1119.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  1120.    
  1121.    TimerCloseOk = cTimerClose(TimerHandle)
  1122.  
  1123. End Sub
  1124.