home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch13 / discount / discount.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  6.4 KB  |  201 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAutomation 
  3.    Caption         =   "OLE Automation"
  4.    ClientHeight    =   2295
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   2295
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.TextBox txtResult 
  13.       BeginProperty Font 
  14.          Name            =   "MS Sans Serif"
  15.          Size            =   9.75
  16.          Charset         =   0
  17.          Weight          =   400
  18.          Underline       =   0   'False
  19.          Italic          =   0   'False
  20.          Strikethrough   =   0   'False
  21.       EndProperty
  22.       Height          =   375
  23.       Left            =   3435
  24.       Locked          =   -1  'True
  25.       TabIndex        =   8
  26.       Top             =   645
  27.       Width           =   1080
  28.    End
  29.    Begin VB.TextBox txtDiscount 
  30.       BeginProperty Font 
  31.          Name            =   "MS Sans Serif"
  32.          Size            =   9.75
  33.          Charset         =   0
  34.          Weight          =   400
  35.          Underline       =   0   'False
  36.          Italic          =   0   'False
  37.          Strikethrough   =   0   'False
  38.       EndProperty
  39.       Height          =   375
  40.       Left            =   1860
  41.       TabIndex        =   7
  42.       Top             =   645
  43.       Width           =   1080
  44.    End
  45.    Begin VB.TextBox txtPrice 
  46.       BeginProperty Font 
  47.          Name            =   "MS Sans Serif"
  48.          Size            =   9.75
  49.          Charset         =   0
  50.          Weight          =   400
  51.          Underline       =   0   'False
  52.          Italic          =   0   'False
  53.          Strikethrough   =   0   'False
  54.       EndProperty
  55.       Height          =   375
  56.       Left            =   315
  57.       TabIndex        =   6
  58.       Top             =   645
  59.       Width           =   1080
  60.    End
  61.    Begin VB.CommandButton cmdClose 
  62.       Cancel          =   -1  'True
  63.       Caption         =   "CLOSE"
  64.       BeginProperty Font 
  65.          Name            =   "MS Sans Serif"
  66.          Size            =   9.75
  67.          Charset         =   0
  68.          Weight          =   400
  69.          Underline       =   0   'False
  70.          Italic          =   0   'False
  71.          Strikethrough   =   0   'False
  72.       EndProperty
  73.       Height          =   495
  74.       Left            =   3330
  75.       TabIndex        =   2
  76.       Top             =   1395
  77.       Width           =   1215
  78.    End
  79.    Begin VB.CommandButton cmdMultiply 
  80.       Caption         =   "Display Discount"
  81.       Default         =   -1  'True
  82.       BeginProperty Font 
  83.          Name            =   "MS Sans Serif"
  84.          Size            =   9.75
  85.          Charset         =   0
  86.          Weight          =   400
  87.          Underline       =   0   'False
  88.          Italic          =   0   'False
  89.          Strikethrough   =   0   'False
  90.       EndProperty
  91.       Height          =   495
  92.       Left            =   240
  93.       TabIndex        =   1
  94.       Top             =   1395
  95.       Width           =   1905
  96.    End
  97.    Begin VB.Label Label1 
  98.       Alignment       =   2  'Center
  99.       BorderStyle     =   1  'Fixed Single
  100.       Caption         =   "Total"
  101.       BeginProperty Font 
  102.          Name            =   "MS Sans Serif"
  103.          Size            =   9.75
  104.          Charset         =   0
  105.          Weight          =   400
  106.          Underline       =   0   'False
  107.          Italic          =   0   'False
  108.          Strikethrough   =   0   'False
  109.       EndProperty
  110.       Height          =   990
  111.       Left            =   3360
  112.       TabIndex        =   5
  113.       Top             =   120
  114.       Width           =   1215
  115.    End
  116.    Begin VB.Label Label4 
  117.       Alignment       =   2  'Center
  118.       BorderStyle     =   1  'Fixed Single
  119.       Caption         =   "Discount"
  120.       BeginProperty Font 
  121.          Name            =   "MS Sans Serif"
  122.          Size            =   9.75
  123.          Charset         =   0
  124.          Weight          =   400
  125.          Underline       =   0   'False
  126.          Italic          =   0   'False
  127.          Strikethrough   =   0   'False
  128.       EndProperty
  129.       Height          =   990
  130.       Left            =   1800
  131.       TabIndex        =   4
  132.       Top             =   120
  133.       Width           =   1215
  134.    End
  135.    Begin VB.Label Label3 
  136.       Alignment       =   2  'Center
  137.       BorderStyle     =   1  'Fixed Single
  138.       Caption         =   "Price"
  139.       BeginProperty Font 
  140.          Name            =   "MS Sans Serif"
  141.          Size            =   9.75
  142.          Charset         =   0
  143.          Weight          =   400
  144.          Underline       =   0   'False
  145.          Italic          =   0   'False
  146.          Strikethrough   =   0   'False
  147.       EndProperty
  148.       Height          =   990
  149.       Left            =   240
  150.       TabIndex        =   3
  151.       Top             =   120
  152.       Width           =   1215
  153.    End
  154.    Begin VB.Label Label2 
  155.       Caption         =   "="
  156.       BeginProperty Font 
  157.          Name            =   "MS Sans Serif"
  158.          Size            =   12
  159.          Charset         =   0
  160.          Weight          =   400
  161.          Underline       =   0   'False
  162.          Italic          =   0   'False
  163.          Strikethrough   =   0   'False
  164.       EndProperty
  165.       Height          =   375
  166.       Left            =   3135
  167.       TabIndex        =   0
  168.       Top             =   405
  169.       Width           =   195
  170.    End
  171. Attribute VB_Name = "frmAutomation"
  172. Attribute VB_GlobalNameSpace = False
  173. Attribute VB_Creatable = False
  174. Attribute VB_PredeclaredId = True
  175. Attribute VB_Exposed = False
  176. Option Explicit
  177. Private Sub cmdClose_Click()
  178.     End
  179. End Sub
  180. Private Sub cmdMultiply_Click()
  181.     Dim XLSheet As Object
  182.     'Open Excel
  183.     ' Change path name for your hard disk
  184.     Set XLSheet = GetObject("C:\My Documents\discount.xls", "Excel.Sheet")
  185.     'Make Excel visible
  186.     XLSheet.Application.Visible = True
  187.     'Equate the first two txt boxes to specific cells
  188.     XLSheet.Cells(2, 3).Value = txtMultiplier1.Text
  189.     XLSheet.Cells(3, 3).Value = txtDiscount.Text
  190.     'Multiply the numbers and display result
  191.     XLSheet.Cells(4, 3).Formula = "=r2c3-(r2c3*r3c3)"
  192.     txtResult.Text = XLSheet.Cells(4, 3)
  193.     XLSheet.SaveAs "C:\My Documents\discoount.xls"
  194.     'Close Excel
  195.     XLSheet.Application.Quit
  196.     'Clear variable
  197.     Set XLSheet = Nothing
  198. End Sub
  199. Private Sub Form_Load()
  200. End Sub
  201.