【发布时间】:2020-10-22 19:05:01
【问题描述】:
我想将 txtQualified 的字符串转换为在数据库中设置为位的布尔值,但它不起作用,错误“无法识别字符串具有有效的布尔值”,请问我该怎么办?
Sub verify()
If aggregate >= CutOffPoint.txtMaleCut.Text AndAlso cmbGender.SelectedItem = "Male" Then
MsgBox("Sorry, You do not Qualify to Offer the Program")
txtQualified.Text = "No"
Convert.ToBoolean(txtQualified.Text)
ElseIf aggregate >= CutOffPoint.txtFemaleCut.Text AndAlso cmbGender.SelectedItem = "Female" Then
MsgBox("Sorry, You do not Qualify to Offer the Program")
txtQualified.Text = "No"
Convert.ToBoolean(txtQualified.Text)
ElseIf aggregate < less Then
MsgBox("Sorry, Invalid Entry, Please Entry all Provided Grades")
Else
MsgBox("Congratulation, You have Qualified")
txtQualified.Text = "Yes"
Convert.ToBoolean(txtQualified.Text)
End If
End Sub
【问题讨论】:
-
为什么首先使用 TextBox 而不是 CheckBox?
-
另外,请注意
Convert.ToBoolean是一个函数,所以如果你确实使用它,你必须将它分配给一个变量,例如isQualified = Convert.ToBoolean(someExpression)。 -
您确定
aggregate >= CutOffPoint.txtMaleCut.Text是正确的检查吗? .Text 属性听起来应该给出一个字符串结果,所以这可能是按字母顺序而不是数值来检查
标签: sql sql-server vb.net boolean data-conversion