home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH11 / 11-3-1.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-02  |  3.2 KB  |  99 lines

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  3. Begin VB.Form frmCosts 
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "Average Expenses of Commuter Students (1995-96)"
  6.    ClientHeight    =   2535
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   6945
  10.    ForeColor       =   &H00000000&
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   2535
  13.    ScaleWidth      =   6945
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin MSFlexGridLib.MSFlexGrid msgCosts 
  16.       Height          =   2535
  17.       Left            =   120
  18.       TabIndex        =   0
  19.       Top             =   0
  20.       Width           =   6735
  21.       _ExtentX        =   11880
  22.       _ExtentY        =   4471
  23.       _Version        =   393216
  24.       Rows            =   9
  25.       Cols            =   5
  26.       FixedRows       =   0
  27.       FixedCols       =   0
  28.       ForeColor       =   0
  29.       GridLines       =   0
  30.       ScrollBars      =   0
  31.       BorderStyle     =   0
  32.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  33.          Name            =   "Courier New"
  34.          Size            =   8.25
  35.          Charset         =   0
  36.          Weight          =   400
  37.          Underline       =   0   'False
  38.          Italic          =   0   'False
  39.          Strikethrough   =   0   'False
  40.       EndProperty
  41.    End
  42. Attribute VB_Name = "frmCosts"
  43. Attribute VB_GlobalNameSpace = False
  44. Attribute VB_Creatable = False
  45. Attribute VB_PredeclaredId = True
  46. Attribute VB_Exposed = False
  47. Private Sub Form_Load()
  48.   Dim rowNum As Integer, colNum As Integer
  49.   Dim strData As String, numData As Single
  50.   'Columns headings
  51.   msgCosts.Row = 0
  52.   msgCosts.Col = 1
  53.   msgCosts.Text = "Pb 2-yr"
  54.   msgCosts.Col = 2
  55.   msgCosts.Text = "Pr 2-yr"
  56.   msgCosts.Col = 3
  57.   msgCosts.Text = "Pb 4-yr"
  58.   msgCosts.Col = 4
  59.   msgCosts.Text = "Pr 4-yr"
  60.   'Read data from data file and obtain column totals
  61.   Dim total(1 To 4) As Single
  62.   Open App.Path & "\STCOSTS.TXT" For Input As #1
  63.   For rowNum = 2 To 6  'row 0 is titles, row 1 is blank
  64.     For colNum = 0 To 4
  65.       msgCosts.Row = rowNum
  66.       msgCosts.Col = colNum
  67.       If colNum = 0 Then
  68.           Input #1, strData
  69.           msgCosts.Text = strData
  70.         Else
  71.           Input #1, numData
  72.           msgCosts.Text = FormatCurrency(numData, 0)
  73.           total(colNum) = total(colNum) + numData
  74.       End If
  75.     Next colNum
  76.   Next rowNum
  77.   'Display totals
  78.   msgCosts.Row = 8
  79.   msgCosts.Col = 0
  80.   msgCosts.Text = "Total"
  81.   For colNum = 1 To 4
  82.     msgCosts.Col = colNum
  83.     msgCosts.Row = 7
  84.     msgCosts.Text = "-------"
  85.     msgCosts.Row = 8
  86.     msgCosts.Text = FormatCurrency(total(colNum), 0)
  87.   Next colNum
  88.   'Set column widths to accomodate data; right-justify dollar amounts
  89.   msgCosts.ColWidth(0) = 2000          'Space for category names
  90.   msgCosts.ColAlignment(0) = 1         'Left alignment
  91.   For colNum = 1 To 4
  92.     msgCosts.ColWidth(colNum) = 1200   'Space for dollar amounts
  93.     msgCosts.ColAlignment(colNum) = 7  'Right alignment
  94.   Next colNum
  95.   'Set overall grid size to minimum needed for the data
  96.   msgCosts.Width = 2000 + 4 * 1200
  97.   msgCosts.Height = 9 * msgCosts.RowHeight(0)
  98. End Sub
  99.