home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Ulli's_Sud2103312252008.psc / cCell.cls < prev    next >
Text File  |  2008-02-25  |  3KB  |  106 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "cCell"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15.  
  16. '#################
  17. 'represents a cell
  18. '#################
  19.  
  20. 'my properties
  21. Private myValue             As Long 'number in this cell
  22. Private myRowNumber         As Long 'row this cell is in
  23. Private myColumnNumber      As Long 'column this cell is in
  24. Private myBlockNumber       As Long 'block this cell is in
  25. Private myFixed             As Boolean 'number in this cell is fixed
  26.  
  27. Friend Property Get BlockNumber() As Long
  28.  
  29.   'returns the block number this cell is member of
  30.  
  31.     BlockNumber = myBlockNumber
  32.  
  33. End Property
  34.  
  35. Friend Property Let Cellnumber(ByVal nuCellNumber As Long)
  36.  
  37.   'uses the cellnumber to calculate the row, column and block this cell is member of
  38.  
  39.     myRowNumber = nuCellNumber \ 9                                          ' 0 to  8 = Row
  40.     myColumnNumber = (nuCellNumber Mod 9) + 9                               ' 9 to 17 = Column
  41.     myBlockNumber = 3 * ((myRowNumber) \ 3) + (myColumnNumber - 9) \ 3 + 18 '18 to 26 = Block
  42.  
  43. End Property
  44.  
  45. Friend Property Get ColumnNumber() As Long
  46.  
  47.   'returns the column number this cell is member of
  48.  
  49.     ColumnNumber = myColumnNumber
  50.  
  51. End Property
  52.  
  53. Friend Property Get Fixed() As Boolean
  54.  
  55.   'returns true if value in this cell is fixed (is an initial value)
  56.  
  57.     Fixed = myFixed
  58.  
  59. End Property
  60.  
  61. Friend Property Let Fixed(nuFixed As Boolean)
  62.  
  63.   'sets or unsets cell fixed
  64.  
  65.     myFixed = nuFixed
  66.  
  67. End Property
  68.  
  69. Friend Property Get RowNumber() As Long
  70.  
  71.   'returns the row number this cell is member of
  72.  
  73.     RowNumber = myRowNumber
  74.  
  75. End Property
  76.  
  77. Friend Property Get Value() As Long
  78.  
  79.   'returns the number in this cell
  80.  
  81.     Value = myValue
  82.  
  83. End Property
  84.  
  85. Friend Property Let Value(ByVal nuValue As Long)
  86.  
  87.   'puts a new value in this cell
  88.  
  89.     If myValue Then 'don't have to add back zero
  90.         Groups(myRowNumber).AddValue myValue 'add the previous value back to available values
  91.         Groups(myColumnNumber).AddValue myValue
  92.         Groups(myBlockNumber).AddValue myValue
  93.     End If
  94.     myValue = nuValue
  95.     If myValue Then 'don't have to remove zero
  96.         Groups(myRowNumber).RemoveValue myValue 'and now remove current value from available values
  97.         Groups(myColumnNumber).RemoveValue myValue
  98.         Groups(myBlockNumber).RemoveValue myValue
  99.     End If
  100.  
  101. End Property
  102.  
  103. ':) Ulli's VB Code Formatter V2.23.17 (2008-Feb-25 09:14)  Decl: 12  Code: 79  Total: 91 Lines
  104. ':) CommentOnly: 14 (15,4%)  Commented: 12 (13,2%)  Empty: 35 (38,5%)  Max Logic Depth: 2
  105. ':) Magic Number: 442372841
  106.