Home > Software engineering >  Updating to use Option Strict On
Updating to use Option Strict On

Time:01-31

I am working on updating a VB.net project to use Option Strict On throughout and seeing this error:

BC32013 Option Strict On disallows operands of type Object for operator '='. Use the 'Is' operator to test for object identity.

However when I try it the code does not work.

Code:

If (dtg_FieldSelector.Rows.Item(m_int_SelectedRow).Cells(0).Value = txt_FieldIndex.Text) Then

CodePudding user response:

you need to stringify the datagrid value as it is Object and Strict on forbids the comparison of two different datatypes

If (dtg_FieldSelector.Rows.Item(m_int_SelectedRow).Cells(0).Value.ToString() = txt_FieldIndex.Text) Then
  • Related