home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk1 / oleauto.fr_ / oleauto.bin
Text File  |  1993-04-28  |  3KB  |  129 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. End
  59. Option Explicit
  60.  
  61. Sub Command1_Click ()
  62.   On Error GoTo errhandle
  63.   ' Display the calculator object and set the object variable.
  64.   Set DispCalc = CreateObject("dispcalc.ccalc")
  65.   ' Enable the square and square root functions.
  66.   command2.Enabled = True
  67.   command3.Enabled = True
  68.   command4.Enabled = True
  69.   Exit Sub
  70.  
  71. errhandle:
  72.   MsgBox "Object Not Created."
  73.   Exit Sub
  74. End Sub
  75.  
  76. Sub Command2_Click ()
  77.   On Error GoTo errhandler
  78.   Dim x As Integer
  79.   ' Get the current value displayed in the calculator.
  80.   x = DispCalc.Value
  81.   ' Square the current value.
  82.   DispCalc.Value = x * x
  83.   ' Display the results.
  84.   DispCalc.Display
  85.   Exit Sub
  86. errhandler:
  87.   ' The dispcalc application cannot display numbers
  88.   ' greater than 32767.
  89.   MsgBox "DispCalc cannot display numbers greater than 32,767."
  90.   Exit Sub
  91. End Sub
  92.  
  93. Sub Command3_Click ()
  94.   Dim x
  95.   ' Calculate the square root of the current value.
  96.   ' Note that the calculator can only display integers.
  97.   DispCalc.Value = Sqr(DispCalc.Value)
  98.   ' Display the new value.
  99.   DispCalc.Display
  100. End Sub
  101.  
  102. Sub Command4_Click ()
  103.   On Error Resume Next
  104.   ' Close the calculator.
  105.   DispCalc.Quit
  106.   ' The object variable DispCalc no longer exists,
  107.   ' so the square and square root functions are
  108.   ' disabled.
  109.   command2.Enabled = False
  110.   command3.Enabled = False
  111.   command4.Enabled = False
  112. End Sub
  113.  
  114. Sub Command5_Click ()
  115.   ' Close the calculator.
  116.   DispCalc.Quit
  117.   ' End the application.
  118.   End
  119. End Sub
  120.  
  121. Sub Form_Load ()
  122.   ' Disable the command buttons until the object variable
  123.   ' is set.
  124.   command2.Enabled = False
  125.   command3.Enabled = False
  126.   command4.Enabled = False
  127. End Sub
  128.  
  129.