从字符串“ BAG”到类型“ Boolean”的转换无效

时间:2019-05-13 08:23:23

标签: vb.net

Private Sub List1_ItemCheck(sender As Object, e As ItemCheckEventArgs) Handles List1.ItemCheck
    Dim m_start As Integer, m_end As Integer
    'MsgBox(List1.SelectedItem.ToString) 

    If List1.SelectedItem.ToString = True Then //in this line m getting error 
        If ComboBox7.Text <> "" Then
            ComboBox7.Text = ComboBox7.Text + ",'" + List1.SelectedItem.ToString + "'"
        Else
            ComboBox7.Text = "'" + List1.SelectedItem.ToString + "'"
        End If
    Else
        m_start = InStr(1, ComboBox7.Text, List1.Text) - 1
        m_end = Len(LTrim(RTrim(List1.Text))) + 1
        If m_start > 0 Then
            ComboBox7.Text = Microsoft.VisualBasic.Left(ComboBox7.Text, m_start - 1) + Microsoft.VisualBasic.Mid(ComboBox7.Text, m_start + m_end + 2)
            If Microsoft.VisualBasic.Right(LTrim(RTrim(ComboBox7.Text)), 1) = "," Then
                ComboBox7.Text = Microsoft.VisualBasic.Left(LTrim(RTrim(ComboBox7.Text)), Len(LTrim(RTrim(ComboBox7.Text))) - 1)
            End If
        End If
    End If
End Sub

0 个答案:

没有答案