我是Visual Basic Express Edition 2010上的构建计算器。
但是当我运行代码时,它就会出错
TextBox3 = c
错误1类型的值'整数'无法转换为System.Windows.Forms.TextBox'。 C:\ Users \ INFRA \ AppData \ Local \ Temporary Projects \ WindowsApplication1 \ Form1.vb 7 20 WindowsApplication1
完整的代码是:
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
结束班
答案 0 :(得分:1)
您需要使用文本框的Text
属性。
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