summaryrefslogtreecommitdiffstats
path: root/private/oleauto/sample/dispcalc/frmdrive.frm
blob: 7cd55f3550520b69ddcc60985559cdfea341155a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
VERSION 2.00
Begin Form frmDriver 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Choose script to run"
   ClientHeight    =   2496
   ClientLeft      =   4800
   ClientTop       =   1380
   ClientWidth     =   3204
   Height          =   2916
   Icon            =   FRMDRIVE.FRX:0000
   Left            =   4752
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   2496
   ScaleWidth      =   3204
   Top             =   1008
   Width           =   3300
   Begin ListBox lstScript 
      Height          =   2520
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   3252
   End
End

Sub lstScript_Click ()

    x = DispCalc.Accum    ' Get Accum property (displayed value).
    
    Select Case lstScript.List(lstScript.ListIndex)
        
        Case "Decrement"
            DispCalc.Accum = x - 1 ' Decrement Accum property and display.
            DispCalc.Display
        
        Case "Count down"
            If DispCalc.Accum < 0 Then
                MsgBox ("Value too small.")
                Exit Sub
            End If
            ' Decrement default property (Accum) till zero.
            Do Until DispCalc = 0
                DispCalc = DispCalc - 1
                DispCalc.Display
            Loop
        
        Case "Cube"
            If DispCalc.Accum > 1000 Then
                MsgBox ("Value too large.")
                Exit Sub
            End If
            DispCalc.Op = 3       ' Use DispCalc's operator method (Op).
            DispCalc.Opnd = x
            DispCalc.Eval         ' Evaluate operation twice (cube).
            DispCalc.Eval
            DispCalc.Display
        
        Case "Factorial"
            If DispCalc.Accum > 16 Then
                MsgBox ("Value too large.")
                Exit Sub
            End If
            DispCalc.Op = 3       ' Use DispCalc's operator method (Op).
            For i = 1 To (x - 1)
                DispCalc.Opnd = i
                DispCalc.Eval
                DispCalc.Display
            Next
        
        Case "Increment"
            DispCalc.Accum = x + 1 ' Increment Accum property and display.
            DispCalc.Display
        
        Case "Square"
            If DispCalc.Accum > 30000 Then
                MsgBox ("Value too large.")
                Exit Sub
            End If
            DispCalc.Op = 3       ' Use DispCalc's operator method (Op).
            DispCalc.Opnd = x
            DispCalc.Eval         ' Evaluate operation once (square).
            DispCalc.Display
        
        Case "Square root"
            If DispCalc.Accum < 1 Then
                MsgBox ("Value too small.")
                Exit Sub
            End If
            DispCalc.Accum = Sqr(x)     ' Use intrinsic function.
            DispCalc.Display            ' Note that Calculator display integers only.
        
        Case "Tangent"
            DispCalc.Value = Tan(x)     ' Use intrinsic function.
            DispCalc.Display            ' Note that Calculator display integers only.
        
        Case "Quit"
            x = MsgBox("Close Calculator?", 35)
            Select Case x
                Case 6          ' If "Yes", then close calculator and end.
                    DispCalc.Quit
                    End
                Case 7          ' If "No", then
                    End         ' leave calculator running.
                Case Else       ' Otherwise, do nothing.
            End Select

        End Select

End Sub