Calculator

R

Rodger

Hello all,

I have seen this question asked before, but I have not found the answer I am
looking for.

This is what I am looking for. I have two options that would work.

Option 1
Have a textbox on the form that would actual work like an Excel Cell and
accept =1+12+34+4 and give me a sum of 51

Option 2
Have a calculator either the one that comes with Windows or create a form
that acts like a basic calculator and the result is returned to my textbox.

That's it, it seems simple . . . . .

TIA,
Rodger
 
R

Rodger

I did in my Original Post . . . . . . .

Here it is . . .
-------------------------------------------------------------
Hello all,

I have seen this question asked before, but I have not found the answer I am
looking for.

This is what I am looking for. I have two options that would work.

Option 1
Have a textbox on the form that would actual work like an Excel Cell and
accept =1+12+34+4 and give me a sum of 51

Option 2
Have a calculator either the one that comes with Windows or create a form
that acts like a basic calculator and the result is returned to my textbox.

That's it, it seems simple . . . . .

TIA,
Rodger
------------------------------------------------------------
 
G

Granny Spitz via AccessMonster.com

Rodger said:
This is what I am looking for. I have two options that would work.

They won't work right unless you use prebuilt applications, like Excel and
your own calculator application, which we can't help you with because we'd
only be guessing.

Option 1 *should* use an Excel spreadsheet to get the right effect. You can
similate it (sort of) by creating 2 text boxes, txtAddNums and txtTotal, and
a button. In the button's click event put this:

Me!txtTotal.Value = Eval(Me!txtAddNums.Value)

It will put the result of the evaluated expression in the txtTotal text box,
but it won't do your data validation for you so this has limited usefulness
unless you want to do a *lot* of coding for *any* mistake which the user
might make.

Option 2 won't put the results of the calculator in your text box unless
*you* create a calculator application which can do this. If you create a
form that acts like a basic calculator, you have a *lot* of coding to fix
*any* mistake which the user might make.

I don't recommend ActiveX controls but you have a third option, the CalcData
control on your toolbox toolbar.
 
M

MikeB

What doesn't work?

I just downloaded it and it works on my XP box, which is what was used for the
Demo.



Rodger said:
I looked at this but the demo does not work.
 
M

MikeB

I can only test it on an Old NT4 box and it craps out there until In the Form
Code Changing the GetMyWindow Function. If you uncomment the WndClassB constant
for NT4 and comment out the WndClassB for XP, it will run on your Win2k Box as
it does on my NT4 Box.
 
R

Rodger

Thanks Mike I figured it was something like that as I tried it on an XP box
and it worked fine. I have an idea, is there a way to close the calculator,
after we click on Copy Results?
 
G

Granny Spitz via AccessMonster.com

MikeB said:
I can only test it on an Old NT4 box and it craps out there until In the Form
Code Changing the GetMyWindow Function. If you uncomment the WndClassB constant
for NT4 and comment out the WndClassB for XP, it will run on your Win2k Box as
it does on my NT4 Box.

Thanks for following up on this, Mike. That looks like the perfect tool for
the job.
 
M

MikeB

Rodger said:
Thanks Mike I figured it was something like that as I tried it on an XP box
and it worked fine. I have an idea, is there a way to close the calculator,
after we click on Copy Results?

Way more involved.

You would need to draw another button on Calculator after it is displayed, then
set a windows hook to capture the onClick event, copying the contents back to
the edit control and closing the calculator at the same event.

Fairly beyond the demo program.
 
D

Dirk Goldgar

Rodger said:
Hello all,

I have seen this question asked before, but I have not found the
answer I am looking for.

This is what I am looking for. I have two options that would work.

Option 1
Have a textbox on the form that would actual work like an Excel Cell
and accept =1+12+34+4 and give me a sum of 51

Here's a rough sample, using code in the text box's AfterUpdate event:

'----- start of code -----
Private Sub Text0_AfterUpdate()

On Error GoTo Err_Handler

If Not IsNull(Me.Text0) Then
Me.Text0 = Eval(Me.Text0)
End If

Exit_Point:
Exit Sub

Err_Handler:
MsgBox "Incomprehensible entry. Please try again."
Resume Exit_Point

End Sub
'----- end of code -----
Option 2
Have a calculator either the one that comes with Windows or create a
form that acts like a basic calculator and the result is returned to
my textbox.

If you search Google, I'm sure you'll find some Access calculator forms
posted out there on the web.
 
R

Rodger

I like that idea. I also think I might have another field store the
calculation before it is calculated so the user can see what they put in to
get the number. Hide the other textbox and have a double click event to
show a msgbox with the contents of the other textbox . . . . .

Now I have two opetion.

Thank you both!

Rodger
 
Top