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
答案 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”。