``````    Dim num1, num2, sum As Double
num1 = txtFirstNum.Text                             A variable input any number can go here
num2 = txtSecondNum.Text                            A variable input any number can go here
sum = num1 + num2
txtoutput.Text = sum
``````

My goal is to have the txtoutput show the equation 2 + 2 = 4
not just the sum 4

I have two input textboxes to enter the integers, a button to add them, and an output txtbox for the solution. Instead of just the sum I need to show the eqaution.

Edited by charles.coogan: Grammer

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by charles.coogan

You have to convert the strings to their integer equivalents with CInt as in

``````num1 = CInt(txtFirstNum.Text)
``````

But you should first check that the string is a valid number by

``````If IsNumeric(txtFirstNum.Text) Then
num1 = CInt(txtFirstNum.Text)
Else
MsgBox("First Number (" & txtFirstNum.Text & ") is not a number")
End If
``````

we are not doing if statements. All I need is the last line to convert the solution into a string that displays both inputs along with an = sign and the answer. Go basic.

``````txtoutput.Text = txtFirstNum.Text  & " + " & _
txtSecondNum.Text & " = " & _
(CInt(txtFirstNum.Text) + CInt(txtSecondNum.Text)).ToString
``````

Edited by Reverend Jim

Great that is what I needed thank you!!!!