我想把txtqualified的字符串转换成boolean,在数据库中它被设置为bit,但是它不起作用,错误“string was not recognized has a valid boolean”,我该怎么办?
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
2条答案
按热度按时间wribegjk1#
尝试将此函数添加到项目中:
但我不明白:你想不带“如果”就这么做吗!?
bkkx9g8r2#
只需编写一个小函数就可以得到布尔值。如果值可能不是yes和no,则可以添加一些验证。
包括
.Add
方法为参数指定正确的数据库数据类型将使操作更安全。