home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / fastmath / vb4sampl.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-04-05  |  15.9 KB  |  534 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "UCALC Fast Math Parser 1.0"
  4.    ClientHeight    =   5430
  5.    ClientLeft      =   1455
  6.    ClientTop       =   1200
  7.    ClientWidth     =   7785
  8.    Height          =   5835
  9.    Left            =   1395
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5430
  12.    ScaleWidth      =   7785
  13.    Top             =   855
  14.    Width           =   7905
  15.    Begin VB.CommandButton Command1 
  16.       Caption         =   "Start"
  17.       Height          =   375
  18.       Left            =   3600
  19.       TabIndex        =   35
  20.       Top             =   4560
  21.       Width           =   615
  22.    End
  23.    Begin VB.TextBox Text10 
  24.       Height          =   285
  25.       Left            =   5640
  26.       TabIndex        =   31
  27.       Top             =   5040
  28.       Width           =   2055
  29.    End
  30.    Begin VB.TextBox Text9 
  31.       Height          =   285
  32.       Left            =   2640
  33.       TabIndex        =   30
  34.       Text            =   "1000"
  35.       Top             =   5040
  36.       Width           =   855
  37.    End
  38.    Begin VB.TextBox Text8 
  39.       Height          =   285
  40.       Left            =   5640
  41.       TabIndex        =   29
  42.       Text            =   "x^2+5x-10"
  43.       Top             =   4680
  44.       Width           =   2055
  45.    End
  46.    Begin VB.CommandButton btnPlot 
  47.       Caption         =   "Plot"
  48.       Height          =   375
  49.       Left            =   6960
  50.       TabIndex        =   21
  51.       Top             =   480
  52.       Width           =   615
  53.    End
  54.    Begin VB.CommandButton btnCalc 
  55.       Caption         =   "Calculate"
  56.       Height          =   375
  57.       Left            =   3480
  58.       TabIndex        =   20
  59.       Top             =   3840
  60.       Width           =   1335
  61.    End
  62.    Begin VB.CommandButton btnFunction 
  63.       Caption         =   "Define Function"
  64.       Height          =   375
  65.       Left            =   3480
  66.       TabIndex        =   19
  67.       Top             =   3360
  68.       Width           =   1335
  69.    End
  70.    Begin VB.CommandButton btnVariable 
  71.       Caption         =   "Define Variable"
  72.       Height          =   375
  73.       Left            =   3480
  74.       TabIndex        =   18
  75.       Top             =   2880
  76.       Width           =   1335
  77.    End
  78.    Begin VB.CommandButton btnEval 
  79.       Caption         =   "Calculate"
  80.       Height          =   375
  81.       Left            =   120
  82.       TabIndex        =   17
  83.       Top             =   1320
  84.       Width           =   1095
  85.    End
  86.    Begin VB.PictureBox Picture1 
  87.       Height          =   1215
  88.       Left            =   3840
  89.       ScaleHeight     =   1155
  90.       ScaleWidth      =   2955
  91.       TabIndex        =   16
  92.       Top             =   840
  93.       Width           =   3015
  94.    End
  95.    Begin VB.TextBox Text7 
  96.       Height          =   285
  97.       Left            =   3840
  98.       TabIndex        =   7
  99.       Text            =   "-sin(x)/2"
  100.       Top             =   480
  101.       Width           =   3015
  102.    End
  103.    Begin VB.TextBox Text6 
  104.       Height          =   285
  105.       Left            =   720
  106.       TabIndex        =   6
  107.       Text            =   "(result)"
  108.       Top             =   4320
  109.       Width           =   2655
  110.    End
  111.    Begin VB.TextBox Text5 
  112.       Height          =   285
  113.       Left            =   720
  114.       TabIndex        =   5
  115.       Text            =   "test*area(3.5,10)+1234"
  116.       Top             =   3840
  117.       Width           =   2655
  118.    End
  119.    Begin VB.TextBox Text4 
  120.       Height          =   285
  121.       Left            =   720
  122.       TabIndex        =   4
  123.       Text            =   "area(length,width)=length*width"
  124.       Top             =   3360
  125.       Width           =   2655
  126.    End
  127.    Begin VB.TextBox Text3 
  128.       Height          =   285
  129.       Left            =   720
  130.       TabIndex        =   3
  131.       Text            =   "test=100"
  132.       Top             =   2880
  133.       Width           =   2655
  134.    End
  135.    Begin VB.TextBox Text2 
  136.       Height          =   285
  137.       Left            =   720
  138.       TabIndex        =   2
  139.       Text            =   "(result)"
  140.       Top             =   840
  141.       Width           =   2655
  142.    End
  143.    Begin VB.TextBox Text1 
  144.       Height          =   285
  145.       Left            =   720
  146.       TabIndex        =   1
  147.       Text            =   "3+4/5-8"
  148.       Top             =   480
  149.       Width           =   2655
  150.    End
  151.    Begin VB.Label Label19 
  152.       Caption         =   "Elapsed (sec) / Answer:"
  153.       Height          =   255
  154.       Left            =   3840
  155.       TabIndex        =   34
  156.       Top             =   5040
  157.       Width           =   1815
  158.    End
  159.    Begin VB.Label Label18 
  160.       Caption         =   "User Expression:"
  161.       Height          =   255
  162.       Left            =   4320
  163.       TabIndex        =   33
  164.       Top             =   4680
  165.       Width           =   1215
  166.    End
  167.    Begin VB.Label Label17 
  168.       Caption         =   "Summation from 1 to:"
  169.       Height          =   375
  170.       Left            =   1800
  171.       TabIndex        =   32
  172.       Top             =   4920
  173.       Width           =   855
  174.    End
  175.    Begin VB.Label Label16 
  176.       Alignment       =   2  'Center
  177.       BackColor       =   &H00FFFFC0&
  178.       BorderStyle     =   1  'Fixed Single
  179.       Caption         =   "Speed Test"
  180.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  181.          Name            =   "MS Sans Serif"
  182.          Size            =   9.75
  183.          Charset         =   0
  184.          Weight          =   700
  185.          Underline       =   0   'False
  186.          Italic          =   0   'False
  187.          Strikethrough   =   0   'False
  188.       EndProperty
  189.       Height          =   375
  190.       Left            =   120
  191.       TabIndex        =   28
  192.       Top             =   4920
  193.       Width           =   1575
  194.    End
  195.    Begin VB.Line Line17 
  196.       BorderWidth     =   2
  197.       X1              =   120
  198.       X2              =   3480
  199.       Y1              =   4800
  200.       Y2              =   4800
  201.    End
  202.    Begin VB.Line Line16 
  203.       BorderWidth     =   2
  204.       X1              =   3480
  205.       X2              =   3480
  206.       Y1              =   4800
  207.       Y2              =   4440
  208.    End
  209.    Begin VB.Line Line15 
  210.       BorderWidth     =   2
  211.       X1              =   3480
  212.       X2              =   7680
  213.       Y1              =   4440
  214.       Y2              =   4440
  215.    End
  216.    Begin VB.Label Label15 
  217.       Caption         =   "Text2 = ucEval(Text1)"
  218.       Height          =   255
  219.       Left            =   1800
  220.       TabIndex        =   27
  221.       Top             =   1560
  222.       Width           =   1695
  223.    End
  224.    Begin VB.Label Label14 
  225.       Caption         =   "Source Code:"
  226.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  227.          Name            =   "MS Sans Serif"
  228.          Size            =   8.25
  229.          Charset         =   0
  230.          Weight          =   400
  231.          Underline       =   -1  'True
  232.          Italic          =   0   'False
  233.          Strikethrough   =   0   'False
  234.       EndProperty
  235.       Height          =   255
  236.       Left            =   1800
  237.       TabIndex        =   26
  238.       Top             =   1320
  239.       Width           =   1095
  240.    End
  241.    Begin VB.Line Line14 
  242.       X1              =   1560
  243.       X2              =   1680
  244.       Y1              =   1680
  245.       Y2              =   1560
  246.    End
  247.    Begin VB.Line Line13 
  248.       X1              =   1680
  249.       X2              =   1560
  250.       Y1              =   1560
  251.       Y2              =   1440
  252.    End
  253.    Begin VB.Line Line12 
  254.       X1              =   1320
  255.       X2              =   1680
  256.       Y1              =   1560
  257.       Y2              =   1560
  258.    End
  259.    Begin VB.Label Label13 
  260.       Caption         =   "Text6 = ucEval(Text5)"
  261.       Height          =   255
  262.       Left            =   5760
  263.       TabIndex        =   25
  264.       Top             =   3960
  265.       Width           =   1935
  266.    End
  267.    Begin VB.Label Label12 
  268.       Caption         =   "ucDefineFunction Text4"
  269.       Height          =   255
  270.       Left            =   5760
  271.       TabIndex        =   24
  272.       Top             =   3480
  273.       Width           =   1935
  274.    End
  275.    Begin VB.Label Label11 
  276.       Caption         =   "ucDefineVariable Text3"
  277.       Height          =   255
  278.       Left            =   5760
  279.       TabIndex        =   23
  280.       Top             =   3000
  281.       Width           =   1935
  282.    End
  283.    Begin VB.Label Label10 
  284.       Caption         =   "Source Code:"
  285.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  286.          Name            =   "MS Sans Serif"
  287.          Size            =   8.25
  288.          Charset         =   0
  289.          Weight          =   400
  290.          Underline       =   -1  'True
  291.          Italic          =   0   'False
  292.          Strikethrough   =   0   'False
  293.       EndProperty
  294.       Height          =   255
  295.       Left            =   5760
  296.       TabIndex        =   22
  297.       Top             =   2520
  298.       Width           =   1095
  299.    End
  300.    Begin VB.Line Line11 
  301.       X1              =   5280
  302.       X2              =   5400
  303.       Y1              =   4200
  304.       Y2              =   4080
  305.    End
  306.    Begin VB.Line Line10 
  307.       X1              =   5400
  308.       X2              =   5280
  309.       Y1              =   4080
  310.       Y2              =   3960
  311.    End
  312.    Begin VB.Line Line9 
  313.       X1              =   5040
  314.       X2              =   5400
  315.       Y1              =   4080
  316.       Y2              =   4080
  317.    End
  318.    Begin VB.Line Line8 
  319.       X1              =   5280
  320.       X2              =   5400
  321.       Y1              =   3720
  322.       Y2              =   3600
  323.    End
  324.    Begin VB.Line Line7 
  325.       X1              =   5400
  326.       X2              =   5280
  327.       Y1              =   3600
  328.       Y2              =   3480
  329.    End
  330.    Begin VB.Line Line6 
  331.       X1              =   5040
  332.       X2              =   5400
  333.       Y1              =   3600
  334.       Y2              =   3600
  335.    End
  336.    Begin VB.Line Line5 
  337.       X1              =   5280
  338.       X2              =   5400
  339.       Y1              =   3240
  340.       Y2              =   3120
  341.    End
  342.    Begin VB.Line Line4 
  343.       X1              =   5400
  344.       X2              =   5280
  345.       Y1              =   3120
  346.       Y2              =   3000
  347.    End
  348.    Begin VB.Line Line3 
  349.       X1              =   5040
  350.       X2              =   5400
  351.       Y1              =   3120
  352.       Y2              =   3120
  353.    End
  354.    Begin VB.Label Label9 
  355.       Caption         =   "Example usng ucEvaluate() in a time-critical loop"
  356.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  357.          Name            =   "MS Sans Serif"
  358.          Size            =   8.25
  359.          Charset         =   0
  360.          Weight          =   400
  361.          Underline       =   -1  'True
  362.          Italic          =   0   'False
  363.          Strikethrough   =   0   'False
  364.       EndProperty
  365.       Height          =   255
  366.       Left            =   3840
  367.       TabIndex        =   15
  368.       Top             =   120
  369.       Width           =   3735
  370.    End
  371.    Begin VB.Line Line2 
  372.       BorderWidth     =   2
  373.       X1              =   3600
  374.       X2              =   3600
  375.       Y1              =   120
  376.       Y2              =   2280
  377.    End
  378.    Begin VB.Line Line1 
  379.       BorderWidth     =   2
  380.       X1              =   7680
  381.       X2              =   120
  382.       Y1              =   2280
  383.       Y2              =   2280
  384.    End
  385.    Begin VB.Label Label8 
  386.       Caption         =   "Example with a user-defined variable and function"
  387.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  388.          Name            =   "MS Sans Serif"
  389.          Size            =   8.25
  390.          Charset         =   0
  391.          Weight          =   400
  392.          Underline       =   -1  'True
  393.          Italic          =   0   'False
  394.          Strikethrough   =   0   'False
  395.       EndProperty
  396.       Height          =   255
  397.       Left            =   720
  398.       TabIndex        =   14
  399.       Top             =   2520
  400.       Width           =   3615
  401.    End
  402.    Begin VB.Label Label7 
  403.       Caption         =   "Text4:"
  404.       Height          =   255
  405.       Left            =   120
  406.       TabIndex        =   13
  407.       Top             =   3360
  408.       Width           =   615
  409.    End
  410.    Begin VB.Label Label6 
  411.       Caption         =   "Text5:"
  412.       Height          =   255
  413.       Left            =   120
  414.       TabIndex        =   12
  415.       Top             =   3840
  416.       Width           =   615
  417.    End
  418.    Begin VB.Label Label5 
  419.       Caption         =   "Text6:"
  420.       Height          =   255
  421.       Left            =   120
  422.       TabIndex        =   11
  423.       Top             =   4320
  424.       Width           =   615
  425.    End
  426.    Begin VB.Label Label4 
  427.       Caption         =   "Text3:"
  428.       Height          =   255
  429.       Left            =   120
  430.       TabIndex        =   10
  431.       Top             =   2880
  432.       Width           =   615
  433.    End
  434.    Begin VB.Label Label3 
  435.       Caption         =   "Text2:"
  436.       Height          =   255
  437.       Left            =   120
  438.       TabIndex        =   9
  439.       Top             =   840
  440.       Width           =   615
  441.    End
  442.    Begin VB.Label Label2 
  443.       Caption         =   "Text1:"
  444.       Height          =   255
  445.       Left            =   120
  446.       TabIndex        =   8
  447.       Top             =   480
  448.       Width           =   615
  449.    End
  450.    Begin VB.Label Label1 
  451.       Caption         =   "Example using ucEval() for simplicity"
  452.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  453.          Name            =   "MS Sans Serif"
  454.          Size            =   8.25
  455.          Charset         =   0
  456.          Weight          =   400
  457.          Underline       =   -1  'True
  458.          Italic          =   0   'False
  459.          Strikethrough   =   0   'False
  460.       EndProperty
  461.       Height          =   255
  462.       Left            =   720
  463.       TabIndex        =   0
  464.       Top             =   120
  465.       Width           =   2655
  466.    End
  467. Attribute VB_Name = "Form1"
  468. Attribute VB_Creatable = False
  469. Attribute VB_Exposed = False
  470. Private Sub Command1_Click()
  471.     Dim x As Double, UserEq As Long, VarX As Integer
  472.     Dim Sum As Double, TimerStart As Single, Elapsed As Single
  473.     Text10 = ""
  474.     Text10.Refresh
  475.     TimerStart = Timer
  476.     VarX = ucDefineVariable("x")
  477.     UserEq = ucParse(Text8)
  478.     For x = 1 To Text9
  479.         ucVariableValue(VarX) = x
  480.         Sum = Sum + ucEvaluate(UserEq)
  481.     Next
  482.     Elapsed = Timer - TimerStart
  483.     Text10 = Int(Elapsed * 100) / 100 & " / " & Sum
  484.     ucReleaseExpr 1
  485. End Sub
  486. Private Sub Form_Load()
  487.     ucalcNull = ucEval("Display opening messages")
  488. End Sub
  489. ' Demonstrates the use of ucEval()
  490. ' Your program should include an error handler
  491. Private Sub btnEval_Click()
  492.     On Error GoTo ErrorHandler
  493.     Text2 = ucEval(Text1)
  494. If ucError = 0 Then Exit Sub
  495. ErrorHandler:
  496.     If Err Then MsgBox Error$, vbExclamation
  497.     If ucError Then MsgBox ucErrorMessage(-1), vbExclamation
  498. End Sub
  499. ' Demonstrates the fast ucEvaluate() function
  500. Private Sub btnPlot_Click()
  501.     Dim x As Double, UserEq As Long, VariableX As Long
  502.     On Error Resume Next
  503.     Picture1.Cls
  504.     Picture1.Scale (-10, 2)-(10, -2)
  505.     Picture1.PSet (-10, 0)
  506.     VariableX = ucDefineVariable("x")
  507.     UserEq = ucParse(Text7)
  508.     For x = -10 To 10 Step 0.5
  509.         ucVariableValue(VariableX) = x
  510.         Picture1.Line -(x, ucEvaluate(UserEq))
  511.     Next
  512.     ucReleaseExpr 1
  513. End Sub
  514. ' Defines a function at runtime
  515. Private Sub btnFunction_Click()
  516.     ' On Error Goto ...
  517.     ucDefineFunction Text4
  518. End Sub
  519. ' Defines a variable at runtime
  520. Private Sub btnVariable_Click()
  521.     ' On Error GoTo ...
  522.     ucDefineVariable Text3
  523. End Sub
  524. ' Example using the one-step ucEval() function
  525. ' Your program should include an error handler
  526. Private Sub btnCalc_Click()
  527.     On Error GoTo ErrorHandler
  528.     Text6 = ucEval(Text5)
  529. If ucError = 0 Then Exit Sub
  530. ErrorHandler:
  531.     If Err Then MsgBox Error$, vbExclamation
  532.     If ucError Then MsgBox ucErrorMessage(-1), vbExclamation
  533. End Sub
  534.