home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l407 / 1.ddi / OLEAUTO.FR_ / OLEAUTO.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  3.3 KB  |  120 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "OLE Automation Demo"
  5.    ClientHeight    =   2040
  6.    ClientLeft      =   2520
  7.    ClientTop       =   2145
  8.    ClientWidth     =   2850
  9.    Height          =   2445
  10.    Left            =   2460
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2040
  15.    ScaleWidth      =   2850
  16.    Top             =   1800
  17.    Width           =   2970
  18.    Begin CommandButton Command5 
  19.       Caption         =   "End Demo"
  20.       Height          =   405
  21.       Left            =   135
  22.       TabIndex        =   4
  23.       Top             =   975
  24.       Width           =   2565
  25.    End
  26.    Begin CommandButton Command4 
  27.       Caption         =   "Close Calculator"
  28.       Height          =   405
  29.       Left            =   135
  30.       TabIndex        =   3
  31.       Top             =   510
  32.       Width           =   2565
  33.    End
  34.    Begin CommandButton Command3 
  35.       Caption         =   "Square Root"
  36.       Height          =   495
  37.       Left            =   1470
  38.       TabIndex        =   2
  39.       Top             =   1470
  40.       Width           =   1215
  41.    End
  42.    Begin CommandButton Command2 
  43.       Caption         =   "Square"
  44.       Height          =   495
  45.       Left            =   165
  46.       TabIndex        =   1
  47.       Top             =   1470
  48.       Width           =   1215
  49.    End
  50.    Begin CommandButton Command1 
  51.       Caption         =   "Display Calculator"
  52.       Height          =   375
  53.       Left            =   120
  54.       TabIndex        =   0
  55.       Top             =   75
  56.       Width           =   2565
  57.    End
  58. Option Explicit
  59. Sub Command1_Click ()
  60.   On Error GoTo errhandle
  61.   ' Display the calculator object and set the object variable.
  62.   Set DispCalc = CreateObject("dispcalc.ccalc")
  63.   ' Enable the square and square root functions.
  64.   command2.Enabled = True
  65.   command3.Enabled = True
  66.   command4.Enabled = True
  67.   Exit Sub
  68. errhandle:
  69.   MsgBox "Object Not Created."
  70.   Exit Sub
  71. End Sub
  72. Sub Command2_Click ()
  73.   On Error GoTo errhandler
  74.   Dim x As Integer
  75.   ' Get the current value displayed in the calculator.
  76.   x = DispCalc.Value
  77.   ' Square the current value.
  78.   DispCalc.Value = x * x
  79.   ' Display the results.
  80.   DispCalc.Display
  81.   Exit Sub
  82. errhandler:
  83.   ' The dispcalc application cannot display numbers
  84.   ' greater than 32767.
  85.   MsgBox "DispCalc cannot display numbers greater than 32,767."
  86.   Exit Sub
  87. End Sub
  88. Sub Command3_Click ()
  89.   Dim x
  90.   ' Calculate the square root of the current value.
  91.   ' Note that the calculator can only display integers.
  92.   DispCalc.Value = Sqr(DispCalc.Value)
  93.   ' Display the new value.
  94.   DispCalc.Display
  95. End Sub
  96. Sub Command4_Click ()
  97.   On Error Resume Next
  98.   ' Close the calculator.
  99.   DispCalc.Quit
  100.   ' The object variable DispCalc no longer exists,
  101.   ' so the square and square root functions are
  102.   ' disabled.
  103.   command2.Enabled = False
  104.   command3.Enabled = False
  105.   command4.Enabled = False
  106. End Sub
  107. Sub Command5_Click ()
  108.   ' Close the calculator.
  109.   DispCalc.Quit
  110.   ' End the application.
  111.   End
  112. End Sub
  113. Sub Form_Load ()
  114.   ' Disable the command buttons until the object variable
  115.   ' is set.
  116.   command2.Enabled = False
  117.   command3.Enabled = False
  118.   command4.Enabled = False
  119. End Sub
  120.