home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch07 / grid1 / grid1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  7.2 KB  |  229 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            =   "Times New Roman"
  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            =   "Times New Roman"
  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            =   "Times New Roman"
  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            =   "Times New Roman"
  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.       Rows            =   13
  90.       Cols            =   4
  91.       AllowBigSelection=   0   'False
  92.       AllowUserResizing=   1
  93.    End
  94.    Begin VB.Label Label1 
  95.       Alignment       =   2  'Center
  96.       BorderStyle     =   1  'Fixed Single
  97.       Caption         =   "Profit Comparison Table"
  98.       BeginProperty Font 
  99.          Name            =   "Times New Roman"
  100.          Size            =   15.75
  101.          Charset         =   0
  102.          Weight          =   400
  103.          Underline       =   0   'False
  104.          Italic          =   0   'False
  105.          Strikethrough   =   0   'False
  106.       EndProperty
  107.       Height          =   540
  108.       Left            =   360
  109.       TabIndex        =   3
  110.       Top             =   45
  111.       Width           =   6120
  112.    End
  113. Attribute VB_Name = "Form1"
  114. Attribute VB_GlobalNameSpace = False
  115. Attribute VB_Creatable = False
  116. Attribute VB_PredeclaredId = True
  117. Attribute VB_Exposed = False
  118. Option Explicit
  119. Dim MonthNames(12) As String
  120. Dim Profit96(12) As Integer
  121. Dim Profit97(12) As Integer
  122. Private Sub Command1_Click()
  123. MonthNames(1) = "January"
  124. MonthNames(2) = "February"
  125. MonthNames(3) = "March"
  126. MonthNames(4) = "April"
  127. MonthNames(5) = "May"
  128. MonthNames(6) = "June"
  129. MonthNames(7) = "July"
  130. MonthNames(8) = "August"
  131. MonthNames(9) = "September"
  132. MonthNames(10) = "October"
  133. MonthNames(11) = "November"
  134. MonthNames(12) = "December"
  135. Profit96(1) = 22060
  136. Profit96(2) = 21440
  137. Profit96(3) = 20450
  138. Profit96(4) = 19020
  139. Profit96(5) = 18130
  140. Profit96(6) = 19640
  141. Profit96(7) = 22150
  142. Profit96(8) = 21500
  143. Profit96(9) = 23460
  144. Profit96(10) = 22430
  145. Profit96(11) = 20190
  146. Profit96(12) = 19700
  147. Profit97(1) = 22250
  148. Profit97(2) = 22240
  149. Profit97(3) = 18160
  150. Profit97(4) = 18940
  151. Profit97(5) = 19500
  152. Profit97(6) = 22440
  153. Profit97(7) = 23650
  154. Profit97(8) = 22310
  155. Profit97(9) = 18140
  156. Profit97(10) = 20050
  157. Profit97(11) = 20160
  158. Profit97(12) = 21400
  159. Dim irow As Integer
  160. For irow = 1 To 12
  161.     Grid.TextMatrix(irow, 1) = MonthNames(irow)
  162.     Grid.TextMatrix(irow, 2) = Format$(Profit97(irow), "#,###")
  163.     Grid.TextMatrix(irow, 3) = Format$(Profit96(irow), "#,###")
  164.     Grid.TextMatrix(irow, 4) = Format$(Grid.TextMatrix(irow, 3) - Grid.TextMatrix(irow, 2), "#,###")
  165.     Grid.TextMatrix(irow, 5) = Format$(100 * (Grid.TextMatrix(irow, 3) - Grid.TextMatrix(irow, 2)) / Grid.TextMatrix(irow, 2), "#.##") & "%"
  166. End Sub
  167. Private Sub Command2_Click()
  168.     Grid.Clear
  169.     Grid.FormatString = "    |<  MONTH  |>  1996 Profit  |>  1997 Profit  |>  Gain   |>  Gain (%)  "
  170. ' Make title row bold
  171.     Grid.FillStyle = flexFillRepeat
  172.     Grid.Row = 0
  173.     Grid.ColSel = Grid.Cols - 1
  174.     Grid.CellFontBold = True
  175.     Grid.FillStyle = flexFillSingle
  176.     Grid.Row = 1
  177.     Grid.ColSel = 1
  178. End Sub
  179. Private Sub Command3_Click()
  180.     Grid.Clear
  181.     Grid.FormatString = " |>  1996 Profit  |>  1997 Profit  |>  Gain   |>  Gain (%)  ;|  January   |  February   |  March   |  April   |  May   |  June   |  July   |  August   |  September   |  October   |  November   |  December   "
  182. ' Make title row bold
  183.     Grid.FillStyle = flexFillRepeat
  184.     Grid.Row = 0
  185.     Grid.ColSel = Grid.Cols - 1
  186.     Grid.CellFontBold = True
  187.     Grid.FillStyle = flexFillSingle
  188. ' Make title column bold
  189.     Grid.FillStyle = flexFillRepeat
  190.     Grid.Col = 0
  191.     Grid.RowSel = Grid.Rows - 1
  192.     Grid.CellFontBold = True
  193.     Grid.FillStyle = flexFillSingle
  194.     Grid.Row = 1
  195.     Grid.ColSel = 1
  196. End Sub
  197. Private Sub Command4_Click()
  198. Profit96(1) = 27060
  199. Profit96(2) = 25440
  200. Profit96(3) = 24450
  201. Profit96(4) = 29020
  202. Profit96(5) = 28130
  203. Profit96(6) = 29640
  204. Profit96(7) = 22150
  205. Profit96(8) = 26500
  206. Profit96(9) = 23460
  207. Profit96(10) = 24430
  208. Profit96(11) = 27190
  209. Profit96(12) = 30700
  210. Profit97(1) = 31250
  211. Profit97(2) = 30240
  212. Profit97(3) = 28160
  213. Profit97(4) = 28940
  214. Profit97(5) = 27950
  215. Profit97(6) = 25440
  216. Profit97(7) = 30650
  217. Profit97(8) = 31310
  218. Profit97(9) = 32140
  219. Profit97(10) = 30200
  220. Profit97(11) = 26160
  221. Profit97(12) = 27140
  222. Dim irow As Integer
  223. For irow = 1 To 12
  224.     Grid.TextMatrix(irow, 1) = Format$(Profit97(irow), "#,###")
  225.     Grid.TextMatrix(irow, 2) = Format$(Profit96(irow), "#,###")
  226.     Grid.TextMatrix(irow, 3) = Format$(Grid.TextMatrix(irow, 2) - Grid.TextMatrix(irow, 1), "#,###")
  227.     Grid.TextMatrix(irow, 4) = Format$(100 * (Grid.TextMatrix(irow, 2) - Grid.TextMatrix(irow, 1)) / Grid.TextMatrix(irow, 1), "#.##") & "%"
  228. End Sub
  229.