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 / CH5 / 5-2-2.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-02  |  2.7 KB  |  92 lines

  1. VERSION 5.00
  2. Begin VB.Form frm5_2_2 
  3.    Caption         =   "Profit/Loss"
  4.    ClientHeight    =   2250
  5.    ClientLeft      =   2190
  6.    ClientTop       =   1740
  7.    ClientWidth     =   2415
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   2250
  20.    ScaleWidth      =   2415
  21.    Begin VB.PictureBox picResult 
  22.       Height          =   255
  23.       Left            =   120
  24.       ScaleHeight     =   195
  25.       ScaleWidth      =   2115
  26.       TabIndex        =   5
  27.       Top             =   1800
  28.       Width           =   2175
  29.    End
  30.    Begin VB.CommandButton cmdShow 
  31.       Caption         =   "Show Financial Status"
  32.       Height          =   495
  33.       Left            =   120
  34.       TabIndex        =   4
  35.       Top             =   1080
  36.       Width           =   2175
  37.    End
  38.    Begin VB.TextBox txtRev 
  39.       Height          =   285
  40.       Left            =   1080
  41.       TabIndex        =   3
  42.       Top             =   600
  43.       Width           =   1215
  44.    End
  45.    Begin VB.TextBox txtCosts 
  46.       Height          =   285
  47.       Left            =   1080
  48.       TabIndex        =   1
  49.       Top             =   120
  50.       Width           =   1215
  51.    End
  52.    Begin VB.Label lblRev 
  53.       Alignment       =   1  'Right Justify
  54.       Caption         =   "Revenue"
  55.       Height          =   255
  56.       Left            =   0
  57.       TabIndex        =   2
  58.       Top             =   600
  59.       Width           =   855
  60.    End
  61.    Begin VB.Label lblCosts 
  62.       Alignment       =   1  'Right Justify
  63.       Caption         =   "Costs"
  64.       Height          =   255
  65.       Left            =   240
  66.       TabIndex        =   0
  67.       Top             =   120
  68.       Width           =   615
  69.    End
  70. Attribute VB_Name = "frm5_2_2"
  71. Attribute VB_GlobalNameSpace = False
  72. Attribute VB_Creatable = False
  73. Attribute VB_PredeclaredId = True
  74. Attribute VB_Exposed = False
  75. Private Sub cmdShow_Click()
  76.   Dim costs As Single, revenue As Single, profit As Single, loss As Single
  77.   costs = Val(txtCosts.Text)
  78.   revenue = Val(txtRev.Text)
  79.   picResult.Cls
  80.   If costs = revenue Then
  81.       picResult.Print "Break even"
  82.     Else
  83.       If costs < revenue Then
  84.           profit = revenue - costs
  85.           picResult.Print "Profit is "; FormatCurrency(profit)
  86.         Else
  87.           loss = costs - revenue
  88.           picResult.Print "Loss is "; FormatCurrency(loss)
  89.       End If
  90.   End If
  91. End Sub
  92.