calculate equation stored in string
From: Phil (pcgerlach_at_ati-ae.com)
Date: 08/24/04
- Next message: Ken Snell [MVP]: "Re: CopyFile Method problem"
- Previous message: Ken Snell [MVP]: "Re: Goto record number"
- Next in thread: Ken Snell [MVP]: "Re: calculate equation stored in string"
- Reply: Ken Snell [MVP]: "Re: calculate equation stored in string"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 24 Aug 2004 08:03:32 -0700
I'm an amateur and working on a module that uses values
entered by a user in form to fill in variables in an
equation. Its then solved and the answer output to the
form. The equation changes though based on the user's
selection in a listbox and is stored as a string
variable "E".
The problem I'm having is in the calculation. I can't seem
to get the user input variables to fill in the equation.
Both the equation string and the user's variables have the
same "L" and "W" designation. I thought this would
automatically fill-in-the-blank on the equations. When
that failed, I tried to pass the equation to the EVAL
function, but also failed. The one clue I have is that I
can enter the equation exactly as stored in the table
extracted from and it solves it wonderfully. What am I
missing? My code is shown below. Thanks in advance for
your help.
'on error resume next
Dim L As Single
Dim W As Single
Dim A As Single
Dim E As String
L = Forms!fCalc.tbxLen.Value 'store user specified
length in L
W = Forms!fCalc.tbxWid.Value 'store user specified
girth in W
'Find the equation to use based on users selection in list
box and store in E
E = DLookup("Equation", "tOptions", "Forms!
fCalc.lbxOptions = [OptionsID]")
'Fill in user variables and calculate equation
A = Eval(E)
'Output result to form
Forms!fCalc.lblAMain.Caption = A
Forms!fCalc.lblAShdw.Caption = A
- Next message: Ken Snell [MVP]: "Re: CopyFile Method problem"
- Previous message: Ken Snell [MVP]: "Re: Goto record number"
- Next in thread: Ken Snell [MVP]: "Re: calculate equation stored in string"
- Reply: Ken Snell [MVP]: "Re: calculate equation stored in string"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|