Create userform calculator in Excel

M

Mario

alsoHi ,
I'd like to build a calculator in Excel in a Userform as an addin.
It should become a regular calculator with the normal buttons and
a textbox as display.

I already prepared the userform with the needed buttons such as :

Back CE C
MC 7 8 9 /
MR 4 5 6 *
MS 1 2 3 -
M- 0 00 . +
M+ 000 +/-

I'm stuck with the code for capturing the numeric values and the
allowed values.
I know i should only allow the numkeys and a few others , but here i'm
also stuck.
Is it possible to write this in Excel , and if so , could you help me
with the code ?
 
J

Joel

You probably need to use text boxes. Then you have to use Val("1") to read
the characters and convert to numerica values. Declaring variables as
numeric types (long, single, double, float) will in some cases allow vba to
automaticall do the conversions. You should also use ISNUMERIC to check if
the boxes contain numeric values. Possibly disable the boxes so users don't
type in characters only the softeare will be able to place numbers into the
box when the keyboard is pressed.
 
P

Peter T

Reinventing the wheel?

Sub ShowCalc()
Shell "Calc.exe", vbNormalFocus
End Sub

If it doesn't work try with the full path, eg
Shell "C:\Windows\system32\Calc.exe", vbNormalFocus

Regards,
Peter T
 
P

Patrick Molloy

Isn't that what Excel is for? Plus there's the Windows calculator already.

Is this just an excercise in coding?

I found it easier to to use two text boxes, one to the rigth of the other,
with the four maths function buttons vertically between them
with text boxes, all you need to do is (1) trap the first letter isn't a
decimal - if it is, prcede it with a zero, then(2) check if the text isnumeric
 
M

Mario

Thanks for the respons.
to Joel :
I'll try some things and let you know what happens.

To Peter T:
Yes I know , reinventing the wheel.!
But i'll need to develop this calc for special uses.
If i got it working correctly , i'll probably will be able to add
features that are needed for some users.
Thanks for helping me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top