Clnt未声明。为什么?

时间:2011-10-16 00:47:08

标签: vb.net

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
    If txtBookID.Text.Length = 0 Or txtAuthor.Text.Length = 0 Or _
       txtTitle.Text.Length = 0 Or txtPurchasePrice.Text.Length = 0 Or _
       txtSalePrice.Text.Length = 0 Or txtInventory.Text.Length = 0 Then
        MessageBox.Show("Please enter all data.")
        Dim aBook As New clsBook(txtBookID.Text, txtAuthor.Text, _
        txtTitle.Text, CDec(txtPurchasePrice.Text), CDec(txtSalePrice.Text), _
        Clnt(txtInventory.Text))
        aBook.Add()
        lblNumberRecords.Text = books.Count
        MessageBox.Show("Record added to the database.")
        btnClear.PerformClick()
    End If
End Sub

2 个答案:

答案 0 :(得分:5)

代码中的第二个字符是小写的“L”,但它应该是大写“i”。

Clnt 'current
CInt 'correct

答案 1 :(得分:3)

试试这个:

If txtBookID.Text.Length = 0 Or txtAuthor.Text.Length = 0 Or _
   txtTitle.Text.Length = 0 Or txtPurchasePrice.Text.Length = 0 Or _
   txtSalePrice.Text.Length = 0 Or txtInventory.Text.Length = 0 Then
    MessageBox.Show("Please enter all data.")
    Dim aBook As New clsBook(txtBookID.Text, txtAuthor.Text, _
      txtTitle.Text, CDec(txtPurchasePrice.Text), CDec(txtSalePrice.Text), _
      CInt(txtInventory.Text)) 'note CInt and not Clnt
    aBook.Add()
    lblNumberRecords.Text = books.Count
    MessageBox.Show("Record added to the database.")
    btnClear.PerformClick()
End If

函数“c I nt”拼写为“c L nt”。

相关问题