Simple calculator build (have code) need help

ExcelTheCell

Board Regular
Joined
Nov 14, 2010
Messages
158
Well guys i'm not sure will you be able to help because this is code that i made in visual basic studio.. But i have found many similarity's between VBA in Excel and this one.

I'm tring to create simple calculator
textbox1 is number
textbox2 is agregate function (+ or - or * or /)
textbox3 is number
and textbox 4 gives result

here is the code:

HTML:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim number1 As Integer
        Dim number2 As Integer
        Dim Number3 As Integer
        Dim sign As String

        number1 = TextBox1.Text
        sign = TextBox2.Text
        number2 = TextBox3.Text
        Number3 = number1 & sign & number2
        TextBox4.Text = Number3

    End Sub
End Class

Example:
number1= integer = 1
sign= string = +
Number2= integer=2
Numberr=3

Anly idea??
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
not sure you can ADD with text

try

number2 = TextBox3.Text

as

number2 = TextBox3.value
 
Upvote 0
Try

Code:
Private Sub CommandButton1_Click()
TextBox4.Value = Evaluate(Val(TextBox1.Text) & TextBox2.Text & Val(TextBox3.Text))
End Sub

N.B. no error check!!
 
Upvote 0
Tnx Vog that solved the problem...

[EDIT] oh no it isn't now what ever u write + or - or * it will give me result 3.. but we have some progress
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,544
Members
452,925
Latest member
duyvmex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top