ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create userform calculator in Excel (https://www.excelbanter.com/excel-programming/433797-create-userform-calculator-excel.html)

Mario[_11_]

Create userform calculator in Excel
 
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 ?


joel

Create userform calculator in Excel
 
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.

"Mario" wrote:

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 ?



Peter T

Create userform calculator in Excel
 
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


"Mario" wrote in message
...
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 ?




Patrick Molloy[_2_]

Create userform calculator in Excel
 
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






"Mario" wrote:

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 ?



Mario[_11_]

Create userform calculator in Excel
 
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.



All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com