user3811206
user3811206

Reputation: 11

Text box does not recognize integer

I am build calculator on Visual Basic Express Edition 2010.

but when I am run code it error this line

TextBox3 = c

Error 1 Value of type 'Integer' cannot be converted to 'System.Windows.Forms.TextBox'. C:\Users\INFRA\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 7 20 WindowsApplication1

Complete code are:

Public Class Form1
Dim a, b, c As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    a = Val(TextBox1)
    b = Val(TextBox2)
    c = a + b
    TextBox3 = c

End Sub

End Class

Upvotes: 0

Views: 1051

Answers (1)

tinstaafl
tinstaafl

Reputation: 6948

You need to use the Text property of the textbox.

Public Class Form1
Dim a, b, c As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    a = Val(TextBox1.Text)
    b = Val(TextBox2.Text)
    c = a + b
    TextBox3.Text = c.ToString()

End Sub

Upvotes: 1

Related Questions