从字符串& quot;& quot;转换键入' Decimal'无效..........
我有这样的代码,它提供与错误"从字符串转换为十进制类型无效
Private Sub btnadd_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理btnadd.Click
     如果txtbookID.Text.Length = 0或者txtauthor.Text.Length = 0或者是
      txttitle.Text.Length = 0或txtpurchaseprice.Text.Length = 0或者
      txtsaleprice.Text.Length = 0或txtinventory.Text.Length = 0然后
          MessageBox.Show("请输入所有数据。")
     否则
          MessageBox.Show("系统会将新记录存储到数据库中。")
          btnclear.PerformClick()
          lblnumberofrecords.Text = lblnumberofrecords.Text()
$
         暗淡abookID作为新clsBook(txtbookID.Text,txtauthor.Text,txttitle.Text,CDEC(txtpurchaseprice.Text),
        &NBSP ;            CDEC(txtsaleprice.Text),CINT(txtinventory.Text))
          lblnumberofrecords.Text = books.Count
          MessageBox.Show("添加到数据库的记录"。)
          btnclear.PerformClick()
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.")
Else
MessageBox.Show("The system will store the new record into the database.")
btnclear.PerformClick()
lblnumberofrecords.Text = lblnumberofrecords.Text()
Dim abookID As New clsBook(txtbookID.Text, txtauthor.Text, txttitle.Text, CDec(txtpurchaseprice.Text),
CDec(txtsaleprice.Text), CInt(txtinventory.Text))
lblnumberofrecords.Text = books.Count
MessageBox.Show("records added to the database.")
btnclear.PerformClick()
b $ b
Dim abookID As New clsBook
(txtbookID.Text, txtauthor.Text, txttitle.Text,
CDec(txtpurchaseprice.Text), CDec(txtsaleprice.Text),
CInt(txtinventory.Text))
。您正在使用CDEC对一些数字值转换为十进制。
我想[txtpurchaseprice],[txtsaleprice]或[txtinventory ]具有无法转换为十进制的值。
在使用[abookID]之前,您需要检查这些控件的值是否可以转换为十进制。 />
问候,
You are using CDEC for converting some numeric value to Decimal.
I suppose [txtpurchaseprice], [txtsaleprice], or [txtinventory] has a value that cannot be converted to Decimal.
You need to check if value of these controls can be converted into Decimal, before using [abookID].
Regards,