Follow in Twitter & Facebook



Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools



Tuesday, April 17, 2012

Conversion from string "FalseFalse" to type 'Boolean' is not valid.

Introduction:
Here we will discuss about one invalidcastException and its solution. The exception is 'Conversion from string "FalseFalse" to type 'Boolean' is not valid'. Also you can see some C#.Net Articles.

Description:
I don't know vb.net syntax. But for practicing purpose while doing one vb sample, i got the
exception like 'Conversion from string "FalseFalse" to type 'Boolean' is not valid'.
This is nothing but one invalidcastexception.At that time my code was like below

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        If txtUserName.Text.Length = 0 Then
            lblSubmit.Text = "UserName can't be blank"
        End If
        If CheckBox1.Checked = False & CheckBox2.Checked = False Then
            lblCheckbox.Text = "You should check atleast one"
      End If
    End Sub
After debuging my application, when i click on the button, i find this error.
Then i searched for the solution, finally i found that solution
The solution is i changed the '&' to 'And' so after that i didn't find that exception
Now my code looks like the below

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        If txtUserName.Text.Length = 0 Then
            lblSubmit.Text = "UserName can't be blank"
        End If
        If CheckBox1.Checked = False And CheckBox2.Checked = False Then
            lblCheckbox.Text = "You should check atleast one"
      End If
    End Sub
 I am sharing the screenshot of that exception . it is as below




0 on: "Conversion from string "FalseFalse" to type 'Boolean' is not valid."