home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX" Begin VB.Form Form1 Caption = "Grid Demo" ClientHeight = 4515 ClientLeft = 60 ClientTop = 345 ClientWidth = 6945 LinkTopic = "Form1" ScaleHeight = 4515 ScaleWidth = 6945 StartUpPosition = 3 'Windows Default Begin VB.CommandButton Command4 Caption = "Display Alternate Data" BeginProperty Font Name = "Verdana" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 645 Left = 5190 TabIndex = 5 Top = 3675 Width = 1710 End Begin VB.CommandButton Command3 Caption = "Display Alternate Titles" BeginProperty Font Name = "Verdana" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 645 Left = 3475 TabIndex = 4 Top = 3675 Width = 1710 End Begin VB.CommandButton Command2 Caption = "Display Titles" BeginProperty Font Name = "Verdana" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 645 Left = 45 TabIndex = 2 Top = 3675 Width = 1710 End Begin VB.CommandButton Command1 Caption = "Display Data" BeginProperty Font Name = "Verdana" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 645 Left = 1760 TabIndex = 1 Top = 3675 Width = 1710 End Begin MSFlexGridLib.MSFlexGrid Grid Height = 2730 Left = 345 TabIndex = 0 Top = 660 Width = 6150 _ExtentX = 10848 _ExtentY = 4815 _Version = 393216 Rows = 13 Cols = 4 AllowBigSelection= -1 'True AllowUserResizing= 1 End Begin VB.Label Label1 Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "Profit Comparison Table" BeginProperty Font Name = "Times New Roman" Size = 15.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 540 Left = 360 TabIndex = 3 Top = 45 Width = 6120 End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False ' ****************************** ' ****************************** ' ** MASTERING VB6 ** ' ** by Evangelos Petroutos ** ' ** SYBEX, 1998 ** ' ****************************** ' ****************************** Option Explicit Dim MonthNames(12) As String Dim Profit96(12) As Integer Dim Profit97(12) As Integer Private Sub Command1_Click() MonthNames(1) = "January" MonthNames(2) = "February" MonthNames(3) = "March" MonthNames(4) = "April" MonthNames(5) = "May" MonthNames(6) = "June" MonthNames(7) = "July" MonthNames(8) = "August" MonthNames(9) = "September" MonthNames(10) = "October" MonthNames(11) = "November" MonthNames(12) = "December" Profit96(1) = 22060 Profit96(2) = 21440 Profit96(3) = 20450 Profit96(4) = 19020 Profit96(5) = 18130 Profit96(6) = 19640 Profit96(7) = 22150 Profit96(8) = 21500 Profit96(9) = 23460 Profit96(10) = 22430 Profit96(11) = 20190 Profit96(12) = 19700 Profit97(1) = 22250 Profit97(2) = 22240 Profit97(3) = 18160 Profit97(4) = 18940 Profit97(5) = 19500 Profit97(6) = 22440 Profit97(7) = 23650 Profit97(8) = 22310 Profit97(9) = 18140 Profit97(10) = 20050 Profit97(11) = 20160 Profit97(12) = 21400 Dim irow As Integer For irow = 1 To 12 Grid.TextMatrix(irow, 1) = MonthNames(irow) Grid.TextMatrix(irow, 2) = Format$(Profit97(irow), "#,###") Grid.TextMatrix(irow, 3) = Format$(Profit96(irow), "#,###") Grid.TextMatrix(irow, 4) = Format$(Grid.TextMatrix(irow, 3) - Grid.TextMatrix(irow, 2), "#,###") Grid.TextMatrix(irow, 5) = Format$(100 * (Grid.TextMatrix(irow, 3) - Grid.TextMatrix(irow, 2)) / Grid.TextMatrix(irow, 2), "#.##") & "%" End Sub Private Sub Command2_Click() Grid.Clear Grid.FormatString = " |< MONTH |> 1996 Profit |> 1997 Profit |> Gain |> Gain (%) " ' Make title row bold Grid.FillStyle = flexFillRepeat Grid.Row = 0 Grid.ColSel = Grid.Cols - 1 Grid.CellFontBold = True Grid.FillStyle = flexFillSingle Grid.Row = 1 Grid.ColSel = 1 End Sub Private Sub Command3_Click() Grid.Clear Grid.FormatString = " |> 1996 Profit |> 1997 Profit |> Gain |> Gain (%) ;| January | February | March | April | May | June | July | August | September | October | November | December " ' Make title row bold Grid.FillStyle = flexFillRepeat Grid.Row = 0 Grid.ColSel = Grid.Cols - 1 Grid.CellFontBold = True Grid.FillStyle = flexFillSingle ' Make title column bold Grid.FillStyle = flexFillRepeat Grid.Col = 0 Grid.RowSel = Grid.Rows - 1 Grid.CellFontBold = True Grid.FillStyle = flexFillSingle Grid.Row = 1 Grid.ColSel = 1 End Sub Private Sub Command4_Click() Profit96(1) = 27060 Profit96(2) = 25440 Profit96(3) = 24450 Profit96(4) = 29020 Profit96(5) = 28130 Profit96(6) = 29640 Profit96(7) = 22150 Profit96(8) = 26500 Profit96(9) = 23460 Profit96(10) = 24430 Profit96(11) = 27190 Profit96(12) = 30700 Profit97(1) = 31250 Profit97(2) = 30240 Profit97(3) = 28160 Profit97(4) = 28940 Profit97(5) = 27950 Profit97(6) = 25440 Profit97(7) = 30650 Profit97(8) = 31310 Profit97(9) = 32140 Profit97(10) = 30200 Profit97(11) = 26160 Profit97(12) = 27140 Dim irow As Integer For irow = 1 To 12 Grid.TextMatrix(irow, 1) = Format$(Profit97(irow), "#,###") Grid.TextMatrix(irow, 2) = Format$(Profit96(irow), "#,###") Grid.TextMatrix(irow, 3) = Format$(Grid.TextMatrix(irow, 2) - Grid.TextMatrix(irow, 1), "#,###") Grid.TextMatrix(irow, 4) = Format$(100 * (Grid.TextMatrix(irow, 2) - Grid.TextMatrix(irow, 1)) / Grid.TextMatrix(irow, 1), "#.##") & "%" End Sub