home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- BorderStyle = 3 'Fixed Double
- Caption = "OLE Automation Demo"
- ClientHeight = 2040
- ClientLeft = 2520
- ClientTop = 2145
- ClientWidth = 2850
- Height = 2445
- Left = 2460
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2040
- ScaleWidth = 2850
- Top = 1800
- Width = 2970
- Begin CommandButton Command5
- Caption = "End Demo"
- Height = 405
- Left = 135
- TabIndex = 4
- Top = 975
- Width = 2565
- End
- Begin CommandButton Command4
- Caption = "Close Calculator"
- Height = 405
- Left = 135
- TabIndex = 3
- Top = 510
- Width = 2565
- End
- Begin CommandButton Command3
- Caption = "Square Root"
- Height = 495
- Left = 1470
- TabIndex = 2
- Top = 1470
- Width = 1215
- End
- Begin CommandButton Command2
- Caption = "Square"
- Height = 495
- Left = 165
- TabIndex = 1
- Top = 1470
- Width = 1215
- End
- Begin CommandButton Command1
- Caption = "Display Calculator"
- Height = 375
- Left = 120
- TabIndex = 0
- Top = 75
- Width = 2565
- End
- Option Explicit
- Sub Command1_Click ()
- On Error GoTo errhandle
- ' Display the calculator object and set the object variable.
- Set DispCalc = CreateObject("dispcalc.ccalc")
- ' Enable the square and square root functions.
- command2.Enabled = True
- command3.Enabled = True
- command4.Enabled = True
- Exit Sub
- errhandle:
- MsgBox "Object Not Created."
- Exit Sub
- End Sub
- Sub Command2_Click ()
- On Error GoTo errhandler
- Dim x As Integer
- ' Get the current value displayed in the calculator.
- x = DispCalc.Value
- ' Square the current value.
- DispCalc.Value = x * x
- ' Display the results.
- DispCalc.Display
- Exit Sub
- errhandler:
- ' The dispcalc application cannot display numbers
- ' greater than 32767.
- MsgBox "DispCalc cannot display numbers greater than 32,767."
- Exit Sub
- End Sub
- Sub Command3_Click ()
- Dim x
- ' Calculate the square root of the current value.
- ' Note that the calculator can only display integers.
- DispCalc.Value = Sqr(DispCalc.Value)
- ' Display the new value.
- DispCalc.Display
- End Sub
- Sub Command4_Click ()
- On Error Resume Next
- ' Close the calculator.
- DispCalc.Quit
- ' The object variable DispCalc no longer exists,
- ' so the square and square root functions are
- ' disabled.
- command2.Enabled = False
- command3.Enabled = False
- command4.Enabled = False
- End Sub
- Sub Command5_Click ()
- ' Close the calculator.
- DispCalc.Quit
- ' End the application.
- End
- End Sub
- Sub Form_Load ()
- ' Disable the command buttons until the object variable
- ' is set.
- command2.Enabled = False
- command3.Enabled = False
- command4.Enabled = False
- End Sub
-