Vb.net 使用未识别的.Items和.Add

Vb.net 使用未识别的.Items和.Add,vb.net,Vb.net,我需要代码方面的帮助: Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click If Ingredients.Text <> "" And QuantityBox.Text <> "" And UnitBox.Text <> "" Then Ingre

我需要代码方面的帮助:

Private Sub AddButton_Click(ByVal sender As System.Object, 
         ByVal e As System.EventArgs) Handles AddButton.Click
    If Ingredients.Text <> "" And QuantityBox.Text <> "" And UnitBox.Text <> "" Then
        Ingredients.Items.Add(ListBox1.Text)
    End If
End Sub
Private Sub AddButton\u单击(ByVal sender作为System.Object,
ByVal e As System.EventArgs)处理添加按钮。单击
如果Components.Text“”和QuantityBox.Text“”以及UnitBox.Text“”,则
配料.项目.添加(列表框1.Text)
如果结束
端接头
在我的第三行,有一个问题。当我尝试调试时,它告诉我“Items不是System.Windows.Form.Textbox的成员。Add也会发生这种情况。我的代码有问题吗,因为我在学校做过这段代码,但在那里没有发生这种问题。

查看您的代码(和大量假设),我想你把列表框和文本框弄混了。试试这个

Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click
    If Ingredients.Text <> "" And QuantityBox.Text <> "" And UnitBox.Text <> "" Then
        ListBox1.Items.Add(Ingredients.Text)
    End If
End Sub
Private Sub AddButton\u Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理AddButton。单击
如果Components.Text“”和QuantityBox.Text“”以及UnitBox.Text“”,则
ListBox1.Items.Add(配料.文本)
如果结束
端接头

如果
成分
是一个
文本框
它没有
属性。我认为您试图给两个不同的对象赋予相同的名称。您不能这样做。