home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch09 / grid1 / grid1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-04-22  |  7.4 KB  |  237 lines

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Grid Demo"
  5.    ClientHeight    =   4515
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   6945
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   4515
  11.    ScaleWidth      =   6945
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.CommandButton Command4 
  14.       Caption         =   "Display Alternate Data"
  15.       BeginProperty Font 
  16.          Name            =   "Verdana"
  17.          Size            =   9.75
  18.          Charset         =   0
  19.          Weight          =   400
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   645
  25.       Left            =   5190
  26.       TabIndex        =   5
  27.       Top             =   3675
  28.       Width           =   1710
  29.    End
  30.    Begin VB.CommandButton Command3 
  31.       Caption         =   "Display Alternate Titles"
  32.       BeginProperty Font 
  33.          Name            =   "Verdana"
  34.          Size            =   9.75
  35.          Charset         =   0
  36.          Weight          =   400
  37.          Underline       =   0   'False
  38.          Italic          =   0   'False
  39.          Strikethrough   =   0   'False
  40.       EndProperty
  41.       Height          =   645
  42.       Left            =   3475
  43.       TabIndex        =   4
  44.       Top             =   3675
  45.       Width           =   1710
  46.    End
  47.    Begin VB.CommandButton Command2 
  48.       Caption         =   "Display Titles"
  49.       BeginProperty Font 
  50.          Name            =   "Verdana"
  51.          Size            =   9.75
  52.          Charset         =   0
  53.          Weight          =   400
  54.          Underline       =   0   'False
  55.          Italic          =   0   'False
  56.          Strikethrough   =   0   'False
  57.       EndProperty
  58.       Height          =   645
  59.       Left            =   45
  60.       TabIndex        =   2
  61.       Top             =   3675
  62.       Width           =   1710
  63.    End
  64.    Begin VB.CommandButton Command1 
  65.       Caption         =   "Display Data"
  66.       BeginProperty Font 
  67.          Name            =   "Verdana"
  68.          Size            =   9.75
  69.          Charset         =   0
  70.          Weight          =   400
  71.          Underline       =   0   'False
  72.          Italic          =   0   'False
  73.          Strikethrough   =   0   'False
  74.       EndProperty
  75.       Height          =   645
  76.       Left            =   1760
  77.       TabIndex        =   1
  78.       Top             =   3675
  79.       Width           =   1710
  80.    End
  81.    Begin MSFlexGridLib.MSFlexGrid Grid 
  82.       Height          =   2730
  83.       Left            =   345
  84.       TabIndex        =   0
  85.       Top             =   660
  86.       Width           =   6150
  87.       _ExtentX        =   10848
  88.       _ExtentY        =   4815
  89.       _Version        =   393216
  90.       Rows            =   13
  91.       Cols            =   4
  92.       AllowBigSelection=   -1  'True
  93.       AllowUserResizing=   1
  94.    End
  95.    Begin VB.Label Label1 
  96.       Alignment       =   2  'Center
  97.       BorderStyle     =   1  'Fixed Single
  98.       Caption         =   "Profit Comparison Table"
  99.       BeginProperty Font 
  100.          Name            =   "Times New Roman"
  101.          Size            =   15.75
  102.          Charset         =   0
  103.          Weight          =   400
  104.          Underline       =   0   'False
  105.          Italic          =   0   'False
  106.          Strikethrough   =   0   'False
  107.       EndProperty
  108.       Height          =   540
  109.       Left            =   360
  110.       TabIndex        =   3
  111.       Top             =   45
  112.       Width           =   6120
  113.    End
  114. Attribute VB_Name = "Form1"
  115. Attribute VB_GlobalNameSpace = False
  116. Attribute VB_Creatable = False
  117. Attribute VB_PredeclaredId = True
  118. Attribute VB_Exposed = False
  119. '  ******************************
  120. '  ******************************
  121. '  ** MASTERING VB6            **
  122. '  ** by Evangelos Petroutos   **
  123. '  ** SYBEX, 1998              **
  124. '  ******************************
  125. '  ******************************
  126. Option Explicit
  127. Dim MonthNames(12) As String
  128. Dim Profit96(12) As Integer
  129. Dim Profit97(12) As Integer
  130. Private Sub Command1_Click()
  131. MonthNames(1) = "January"
  132. MonthNames(2) = "February"
  133. MonthNames(3) = "March"
  134. MonthNames(4) = "April"
  135. MonthNames(5) = "May"
  136. MonthNames(6) = "June"
  137. MonthNames(7) = "July"
  138. MonthNames(8) = "August"
  139. MonthNames(9) = "September"
  140. MonthNames(10) = "October"
  141. MonthNames(11) = "November"
  142. MonthNames(12) = "December"
  143. Profit96(1) = 22060
  144. Profit96(2) = 21440
  145. Profit96(3) = 20450
  146. Profit96(4) = 19020
  147. Profit96(5) = 18130
  148. Profit96(6) = 19640
  149. Profit96(7) = 22150
  150. Profit96(8) = 21500
  151. Profit96(9) = 23460
  152. Profit96(10) = 22430
  153. Profit96(11) = 20190
  154. Profit96(12) = 19700
  155. Profit97(1) = 22250
  156. Profit97(2) = 22240
  157. Profit97(3) = 18160
  158. Profit97(4) = 18940
  159. Profit97(5) = 19500
  160. Profit97(6) = 22440
  161. Profit97(7) = 23650
  162. Profit97(8) = 22310
  163. Profit97(9) = 18140
  164. Profit97(10) = 20050
  165. Profit97(11) = 20160
  166. Profit97(12) = 21400
  167. Dim irow As Integer
  168. For irow = 1 To 12
  169.     Grid.TextMatrix(irow, 1) = MonthNames(irow)
  170.     Grid.TextMatrix(irow, 2) = Format$(Profit97(irow), "#,###")
  171.     Grid.TextMatrix(irow, 3) = Format$(Profit96(irow), "#,###")
  172.     Grid.TextMatrix(irow, 4) = Format$(Grid.TextMatrix(irow, 3) - Grid.TextMatrix(irow, 2), "#,###")
  173.     Grid.TextMatrix(irow, 5) = Format$(100 * (Grid.TextMatrix(irow, 3) - Grid.TextMatrix(irow, 2)) / Grid.TextMatrix(irow, 2), "#.##") & "%"
  174. End Sub
  175. Private Sub Command2_Click()
  176.     Grid.Clear
  177.     Grid.FormatString = "    |<  MONTH  |>  1996 Profit  |>  1997 Profit  |>  Gain   |>  Gain (%)  "
  178. ' Make title row bold
  179.     Grid.FillStyle = flexFillRepeat
  180.     Grid.Row = 0
  181.     Grid.ColSel = Grid.Cols - 1
  182.     Grid.CellFontBold = True
  183.     Grid.FillStyle = flexFillSingle
  184.     Grid.Row = 1
  185.     Grid.ColSel = 1
  186. End Sub
  187. Private Sub Command3_Click()
  188.     Grid.Clear
  189.     Grid.FormatString = " |>  1996 Profit  |>  1997 Profit  |>  Gain   |>  Gain (%)  ;|  January   |  February   |  March   |  April   |  May   |  June   |  July   |  August   |  September   |  October   |  November   |  December   "
  190. ' Make title row bold
  191.     Grid.FillStyle = flexFillRepeat
  192.     Grid.Row = 0
  193.     Grid.ColSel = Grid.Cols - 1
  194.     Grid.CellFontBold = True
  195.     Grid.FillStyle = flexFillSingle
  196. ' Make title column bold
  197.     Grid.FillStyle = flexFillRepeat
  198.     Grid.Col = 0
  199.     Grid.RowSel = Grid.Rows - 1
  200.     Grid.CellFontBold = True
  201.     Grid.FillStyle = flexFillSingle
  202.     Grid.Row = 1
  203.     Grid.ColSel = 1
  204. End Sub
  205. Private Sub Command4_Click()
  206. Profit96(1) = 27060
  207. Profit96(2) = 25440
  208. Profit96(3) = 24450
  209. Profit96(4) = 29020
  210. Profit96(5) = 28130
  211. Profit96(6) = 29640
  212. Profit96(7) = 22150
  213. Profit96(8) = 26500
  214. Profit96(9) = 23460
  215. Profit96(10) = 24430
  216. Profit96(11) = 27190
  217. Profit96(12) = 30700
  218. Profit97(1) = 31250
  219. Profit97(2) = 30240
  220. Profit97(3) = 28160
  221. Profit97(4) = 28940
  222. Profit97(5) = 27950
  223. Profit97(6) = 25440
  224. Profit97(7) = 30650
  225. Profit97(8) = 31310
  226. Profit97(9) = 32140
  227. Profit97(10) = 30200
  228. Profit97(11) = 26160
  229. Profit97(12) = 27140
  230. Dim irow As Integer
  231. For irow = 1 To 12
  232.     Grid.TextMatrix(irow, 1) = Format$(Profit97(irow), "#,###")
  233.     Grid.TextMatrix(irow, 2) = Format$(Profit96(irow), "#,###")
  234.     Grid.TextMatrix(irow, 3) = Format$(Grid.TextMatrix(irow, 2) - Grid.TextMatrix(irow, 1), "#,###")
  235.     Grid.TextMatrix(irow, 4) = Format$(100 * (Grid.TextMatrix(irow, 2) - Grid.TextMatrix(irow, 1)) / Grid.TextMatrix(irow, 1), "#.##") & "%"
  236. End Sub
  237.