home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmAutomation
- Caption = "OLE Automation"
- ClientHeight = 2295
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4680
- LinkTopic = "Form1"
- ScaleHeight = 2295
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Begin VB.TextBox txtResult
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 3435
- Locked = -1 'True
- TabIndex = 8
- Top = 645
- Width = 1080
- End
- Begin VB.TextBox txtDiscount
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 1860
- TabIndex = 7
- Top = 645
- Width = 1080
- End
- Begin VB.TextBox txtPrice
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 315
- TabIndex = 6
- Top = 645
- Width = 1080
- End
- Begin VB.CommandButton cmdClose
- Cancel = -1 'True
- Caption = "CLOSE"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 3330
- TabIndex = 2
- Top = 1395
- Width = 1215
- End
- Begin VB.CommandButton cmdMultiply
- Caption = "Display Discount"
- Default = -1 'True
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 240
- TabIndex = 1
- Top = 1395
- Width = 1905
- End
- Begin VB.Label Label1
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = "Total"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 990
- Left = 3360
- TabIndex = 5
- Top = 120
- Width = 1215
- End
- Begin VB.Label Label4
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = "Discount"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 990
- Left = 1800
- TabIndex = 4
- Top = 120
- Width = 1215
- End
- Begin VB.Label Label3
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = "Price"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 990
- Left = 240
- TabIndex = 3
- Top = 120
- Width = 1215
- End
- Begin VB.Label Label2
- Caption = "="
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 3135
- TabIndex = 0
- Top = 405
- Width = 195
- End
- Attribute VB_Name = "frmAutomation"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub cmdClose_Click()
- End
- End Sub
- Private Sub cmdMultiply_Click()
- Dim XLSheet As Object
- 'Open Excel
- ' Change path name for your hard disk
- Set XLSheet = GetObject("C:\My Documents\discount.xls", "Excel.Sheet")
- 'Make Excel visible
- XLSheet.Application.Visible = True
- 'Equate the first two txt boxes to specific cells
- XLSheet.Cells(2, 3).Value = txtMultiplier1.Text
- XLSheet.Cells(3, 3).Value = txtDiscount.Text
- 'Multiply the numbers and display result
- XLSheet.Cells(4, 3).Formula = "=r2c3-(r2c3*r3c3)"
- txtResult.Text = XLSheet.Cells(4, 3)
- XLSheet.SaveAs "C:\My Documents\discoount.xls"
- 'Close Excel
- XLSheet.Application.Quit
- 'Clear variable
- Set XLSheet = Nothing
- End Sub
- Private Sub Form_Load()
- End Sub
-