# Simple calculator build (have code) need help

#### ExcelTheCell

##### Board Regular
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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

#### mole999

##### Moderator
not sure you can ADD with text

try

number2 = TextBox3.Text

as

number2 = TextBox3.value

#### VoG

##### Legend
Try

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

N.B. no error check!!

#### ExcelTheCell

##### Board Regular
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:

Replies
3
Views
48
Replies
2
Views
216
Replies
4
Views
495
Replies
36
Views
2K
Replies
1
Views
1K