home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / CrossLang / MultiGenerator.vb < prev    next >
Encoding:
Text File  |  2000-06-23  |  5.1 KB  |  139 lines

  1. '===========================================================================
  2. '  File:      MultiGenerator.vb
  3. '
  4. '  Summary:   This is the one of the derived classes for the CrossLang sample.
  5. '             This class generates multiplication tables in HTML format.
  6. '
  7. '----------------------------------------------------------------------------
  8. '  This file is part of the Microsoft NGWS Samples.
  9. '
  10. '  Copyright (C) 1998-2000 Microsoft Corporation.  All rights reserved.
  11. '============================================================================
  12.  
  13. Imports System
  14. Imports TableGen
  15.  
  16. NameSpace MultiGen
  17. Public Class MultiGenerator
  18. Inherits TableGenerator
  19.  
  20. ' Member variables that represent the width and height of the multiplication
  21. ' table.  These value are extracted from the string passed to SetParameter.
  22. Dim width As Integer
  23. Dim height As Integer
  24.  
  25. '******************************************************************************
  26. 'Function : SetParameter(byval param as String)
  27. '
  28. 'Abstract: This implementation of SetParameter parses the string to find the
  29. '          width and height of the multiplication table.
  30. '
  31. 'Input Parameters: byval param as String = A String representation of what the
  32. '                  client needs.
  33. '
  34. 'Returns: none.
  35. '******************************************************************************
  36. overrides public sub SetParameter(byval param as String)
  37.  
  38.         ' Take string, parse, get table width and height.
  39.         Dim delimeter As Integer
  40.         delimeter = param.IndexOf("*")
  41.         width = Convert.ToInt32(param.Substring(0, delimeter), 10)
  42.         height = Convert.ToInt32(param.Substring(delimeter + 1, param.Length - (delimeter + 1)), 10)
  43.         
  44.         ' Do simple bounds checking
  45.         If width > 100 Then
  46.                 width = 100
  47.         else if width < 1 then
  48.                 width = 1
  49.         End If
  50.         If height > 100 Then
  51.                 height = 100
  52.         else if height < 1 then
  53.                 height = 1
  54.         End If
  55. End Sub
  56.  
  57. '******************************************************************************
  58. 'Function : GetColumnCount() as Integer
  59. '
  60. 'Abstract: This implementation of GetColumnCount returns the width of the
  61. '          multiplication table.
  62. '
  63. 'Input Parameters: none.
  64. '
  65. 'Returns: Integer = the number of columns for this table.
  66. '******************************************************************************
  67. overrides public function GetColumnCount() as Integer
  68.         GetColumnCount = width + 1
  69. End Function
  70.  
  71. '******************************************************************************
  72. 'Function : GetRowCount() as Integer
  73. '
  74. 'Abstract: This implementation of GetColumnCount returns the height of the
  75. '          multiplication table.
  76. '
  77. 'Input Parameters: none.
  78. '
  79. 'Returns: Integer = the number of rows for this table.
  80. '******************************************************************************
  81. overrides public function GetRowCount() as Integer
  82.         GetRowCount = height + 1
  83. End Function
  84.  
  85. '******************************************************************************
  86. 'Function : GetHeader() as String
  87. '
  88. 'Abstract: This implementation does not use the HTML header.  It returns "".
  89. '
  90. 'Input Parameters: none.
  91. '
  92. 'Returns: String = the HTML header for this table.
  93. '******************************************************************************
  94. overrides public function GetHeader() as String
  95.         GetHeader = ""
  96. End Function
  97.  
  98. '******************************************************************************
  99. 'Function : GetFooter() as String
  100. '
  101. 'Abstract: This implementation does not use the HTML footer.  It returns "".
  102. '
  103. 'Input Parameters: none.
  104. '
  105. 'Returns: String = the HTML footer for this table.
  106. '******************************************************************************
  107. overrides public function GetFooter() as String
  108.         GetFooter = ""
  109. End Function
  110.  
  111. '******************************************************************************
  112. 'Function : GetCell(byval column as Integer, byval row as Integer) as String
  113. '
  114. 'Abstract: This implementation of GetCell calculates the value of the cell for
  115. '          this column and row.
  116. '
  117. 'Input Parameters: byval column as Integer, byval row as Integer = the column and row
  118. '                  to retieve cell data.
  119. '
  120. 'Returns: String = the HTML data that represents the specified cell in this table.
  121. '******************************************************************************
  122. overrides public function GetCell(byval column as Integer, byval row as Integer) as String
  123.         If Column = 0 And row = 0 Then
  124.                 GetCell = ""
  125.         Else
  126.                 If Column = 0 Or row = 0 Then
  127.                         If Column = 0 Then
  128.                                 GetCell = "<B>" & row & "</B>"
  129.                         Else
  130.                                 GetCell = "<B>" & Column & "</B>"
  131.                         End If
  132.                 Else
  133.                         GetCell = Convert.ToString(Column * row)
  134.                 End If
  135.         End If
  136. End Function
  137. End Class
  138.  
  139. End NameSpace