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 / CH8 / 8-2-3.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-02  |  2.9 KB  |  87 lines

  1. VERSION 5.00
  2. Begin VB.Form frm8_2_3 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "8-2-3"
  5.    ClientHeight    =   3990
  6.    ClientLeft      =   1035
  7.    ClientTop       =   1905
  8.    ClientWidth     =   4935
  9.    BeginProperty Font 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   700
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    LinkTopic       =   "Form1"
  19.    MaxButton       =   0   'False
  20.    MinButton       =   0   'False
  21.    PaletteMode     =   1  'UseZOrder
  22.    ScaleHeight     =   3990
  23.    ScaleWidth      =   4935
  24.    ShowInTaskbar   =   0   'False
  25.    Begin VB.PictureBox picReport 
  26.       Height          =   3255
  27.       Left            =   120
  28.       ScaleHeight     =   3195
  29.       ScaleWidth      =   4635
  30.       TabIndex        =   1
  31.       Top             =   600
  32.       Width           =   4695
  33.    End
  34.    Begin VB.CommandButton cmdCreateReport 
  35.       Caption         =   "Create Report"
  36.       Height          =   375
  37.       Left            =   1440
  38.       TabIndex        =   0
  39.       Top             =   120
  40.       Width           =   2055
  41.    End
  42. Attribute VB_Name = "frm8_2_3"
  43. Attribute VB_GlobalNameSpace = False
  44. Attribute VB_Creatable = False
  45. Attribute VB_PredeclaredId = True
  46. Attribute VB_Exposed = False
  47. Private Sub cmdCreateReport_Click()
  48.   Dim currentMonth As String, newMonth As String
  49.   Dim dayNum As Integer, address As String
  50.   Dim price As Single, monthTotal As Single
  51.   Dim yearTotal As Single, doneFlag As Boolean
  52.   'Display home sales by month
  53.   picReport.Cls
  54.   Open App.Path & "\HOMESALE.TXT" For Input As #1
  55.   currentMonth = ""         'Name of month being subtotaled
  56.   monthTotal = 0
  57.   yearTotal = 0
  58.   doneFlag = False              'Flag to indicate end of list
  59.   Do While Not doneFlag
  60.     If Not EOF(1) Then
  61.         Input #1, newMonth, dayNum, address, price
  62.       Else
  63.         doneFlag = True             'End of list
  64.     End If
  65.     If (newMonth <> currentMonth) Or (doneFlag) Then  'Control break processing
  66.         If currentMonth <> "" Then                    'Don't print subtotal before 1st month
  67.             picReport.Print
  68.             picReport.Print Tab(15); "Subtotal for "; currentMonth; ":";
  69.             picReport.Print Tab(38); FormatCurrency(monthTotal)
  70.             picReport.Print
  71.         End If
  72.         currentMonth = newMonth
  73.         monthTotal = 0
  74.     End If
  75.     If Not doneFlag Then
  76.         picReport.Print newMonth;
  77.         picReport.Print Tab(11); FormatNumber(dayNum, 0);
  78.         picReport.Print Tab(18); address;
  79.         picReport.Print Tab(38); FormatCurrency(price)
  80.         yearTotal = yearTotal + price
  81.     End If
  82.     monthTotal = monthTotal + price
  83.   Loop
  84.   Close #1
  85.   picReport.Print "Total for First Quarter: "; FormatCurrency(yearTotal)
  86. End Sub
  87.