home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / base_xp / calc1.frm < prev    next >
Text File  |  1994-01-25  |  2KB  |  96 lines

  1. VERSION 2.00
  2. Begin Form calctest 
  3.    Caption         =   "Sample Expression Evaluator"
  4.    ClientHeight    =   4020
  5.    ClientLeft      =   1680
  6.    ClientTop       =   1410
  7.    ClientWidth     =   7365
  8.    Height          =   4425
  9.    Left            =   1620
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4020
  12.    ScaleWidth      =   7365
  13.    Top             =   1065
  14.    Width           =   7485
  15.    Begin CommandButton Command2 
  16.       Caption         =   "Iterate 10000"
  17.       Height          =   495
  18.       Left            =   4440
  19.       TabIndex        =   4
  20.       Top             =   1440
  21.       Width           =   1695
  22.    End
  23.    Begin TextBox answer 
  24.       Enabled         =   0   'False
  25.       Height          =   375
  26.       Left            =   2700
  27.       TabIndex        =   3
  28.       Top             =   2640
  29.       Width           =   4095
  30.    End
  31.    Begin CommandButton Command1 
  32.       Caption         =   "Calculate"
  33.       Height          =   495
  34.       Left            =   2580
  35.       TabIndex        =   2
  36.       Top             =   1440
  37.       Width           =   1215
  38.    End
  39.    Begin TextBox Text1 
  40.       Height          =   315
  41.       Left            =   2580
  42.       TabIndex        =   1
  43.       Text            =   "((3 + 4) * 5 - 2) * 2 - 1"
  44.       Top             =   540
  45.       Width           =   4035
  46.    End
  47.    Begin Label Label2 
  48.       Caption         =   "Answer"
  49.       Height          =   315
  50.       Left            =   1740
  51.       TabIndex        =   5
  52.       Top             =   2640
  53.       Width           =   915
  54.    End
  55.    Begin Label Label1 
  56.       Alignment       =   1  'Right Justify
  57.       Caption         =   "Formula"
  58.       Height          =   195
  59.       Left            =   1260
  60.       TabIndex        =   0
  61.       Top             =   600
  62.       Width           =   1275
  63.    End
  64. End
  65. Option Explicit
  66.  
  67. Sub Command1_Click ()
  68. answer.Text = ""
  69. answer.Text = eval((text1.Text))
  70. End Sub
  71.  
  72. Sub Command2_Click ()
  73. Dim p$, i%, t$
  74. p = text1.Text
  75. screen.MousePointer = 11
  76. MousePointer = 11
  77. Refresh
  78. For i = 1 To 10000
  79. t = eval(p)
  80. Next
  81. screen.MousePointer = 0
  82. MousePointer = 0
  83. Beep
  84. answer.Text = t
  85. End Sub
  86.  
  87. Sub Form_Load ()
  88.  initcalc
  89. End Sub
  90.  
  91. Sub Text1_GotFocus ()
  92. text1.SelStart = 0
  93. text1.SelLength = Len(text1.Text)
  94. End Sub
  95.  
  96.