home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / bitvctr / bitvectr.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-11-20  |  4.5 KB  |  160 lines

  1. VERSION 4.00
  2. Begin VB.Form frmBitVectorTest 
  3.    Caption         =   "BitVector Class Test"
  4.    ClientHeight    =   4455
  5.    ClientLeft      =   1245
  6.    ClientTop       =   1635
  7.    ClientWidth     =   5715
  8.    Height          =   4890
  9.    Left            =   1170
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   297
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   381
  14.    Top             =   1275
  15.    Width           =   5865
  16.    Begin VB.CommandButton cmdtest4 
  17.       Caption         =   "Test &4"
  18.       Height          =   405
  19.       Left            =   4290
  20.       TabIndex        =   3
  21.       Top             =   1650
  22.       Width           =   1215
  23.    End
  24.    Begin VB.Timer Timer1 
  25.       Interval        =   55
  26.       Left            =   5040
  27.       Top             =   2250
  28.    End
  29.    Begin VB.CommandButton cmdTest3 
  30.       Caption         =   "Test &3"
  31.       Height          =   405
  32.       Left            =   4290
  33.       TabIndex        =   2
  34.       Top             =   1170
  35.       Width           =   1215
  36.    End
  37.    Begin VB.CommandButton cmdTest2 
  38.       Caption         =   "Test &2"
  39.       Height          =   405
  40.       Left            =   4290
  41.       TabIndex        =   1
  42.       Top             =   690
  43.       Width           =   1215
  44.    End
  45.    Begin VB.CommandButton cmdTest1 
  46.       Caption         =   "Test &1"
  47.       Height          =   405
  48.       Left            =   4290
  49.       TabIndex        =   0
  50.       Top             =   210
  51.       Width           =   1215
  52.    End
  53.    Begin VB.Image Image1 
  54.       Height          =   180
  55.       Index           =   1
  56.       Left            =   4710
  57.       Picture         =   "BITVECTR.frx":0000
  58.       Top             =   2370
  59.       Visible         =   0   'False
  60.       Width           =   180
  61.    End
  62.    Begin VB.Image Image1 
  63.       Height          =   180
  64.       Index           =   0
  65.       Left            =   4470
  66.       Picture         =   "BITVECTR.frx":00E2
  67.       Top             =   2370
  68.       Visible         =   0   'False
  69.       Width           =   180
  70.    End
  71. Attribute VB_Name = "frmBitVectorTest"
  72. Attribute VB_Creatable = False
  73. Attribute VB_Exposed = False
  74. ' BitVector Class Test App
  75. ' Copyright 
  76.  1995-1996 by Gregg S. Irwin. All Rights Reserved.
  77. DefInt A-Z
  78. Dim mTestMode As Integer
  79. Dim BV As New BitVector
  80. Private Sub cmdTest1_Click()
  81.     mTestMode = 1
  82.     Cls
  83.     BV.NumElements = 25000
  84.     BV.SetBit 12345
  85.     Print BV.IsBitSet(12345)
  86.     BV.ClearBit 12345
  87.     Print BV.IsBitSet(12345)
  88.     BV.ToggleBit 12345
  89.     Print BV.IsBitSet(12345)
  90.     BV.ToggleBit 12345
  91.     Print BV.IsBitSet(12345)
  92.     On Error GoTo Test1Err
  93.         BV.ToggleBit 25001
  94.     On Error GoTo 0
  95. Test1Exit:
  96.     Exit Sub
  97. Test1Err:
  98.     Print Err.Description, Err.Source
  99.     Resume Next
  100. End Sub
  101. Private Sub cmdTest2_Click()
  102.     mTestMode = 2
  103.     Cls
  104.     BV.NumElements = 4096
  105. End Sub
  106. Private Sub cmdTest3_Click()
  107.     mTestMode = 3
  108.     Cls
  109.     BV.NumElements = 256
  110. End Sub
  111. Private Sub cmdtest4_Click()
  112.     mTestMode = 4
  113.     Cls
  114.     Print "Bit Property Access"
  115.     BV.NumElements = 256
  116.     Print "Bit 1:", BV.Bit(1)
  117.     Print "Setting Bit 1"
  118.     BV.Bit(1) = 1
  119.     Print "Bit 1:", BV.Bit(1)
  120.     On Error Resume Next
  121.         Print "NumElements error handler test"
  122.         BV.NumElements = -1
  123.         If Err Then
  124.             Print Err.Description, Err.Source
  125.         End If
  126.         
  127.         BV.NumElements = 0
  128.         Print "Setting NumElements to 0"
  129.         Print "Accessing Bit 0: (should cause error)"
  130.         Print BV.Bit(0)
  131.         If Err Then
  132.             Print Err.Description, Err.Source
  133.         End If
  134.     On Error GoTo 0
  135. End Sub
  136. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  137.     Dim Row As Integer
  138.     Dim Col As Integer
  139.     Dim Index As Long
  140.     If mTestMode = 2 Then
  141.         Row = X \ 12
  142.         Col = Y \ 12
  143.         Index = Row * Col
  144.         BV.ToggleBit Index
  145.         PaintPicture Image1(BV.GetBit(Index)).Picture, Row * 12, Col * 12
  146.     End If
  147. End Sub
  148. Private Sub Form_Unload(Cancel As Integer)
  149.         
  150.     Set BV = Nothing
  151. End Sub
  152. Private Sub Timer1_Timer()
  153.     Dim Index As Long
  154.     If mTestMode = 3 Then
  155.         Index = CLng(Rnd * (BV.NumElements - 1))
  156.         BV.ToggleBit Index
  157.         PaintPicture Image1(BV.GetBit(Index)).Picture, (Index \ 16) * 12, (Index Mod 16) * 12
  158.     End If
  159. End Sub
  160.