none
Optin Strict On - Late Binding error RRS feed

  • Question

  • Hi all

    i'm working with Option Strict On and I get error on this sub

     Private Sub GetPKLastRowSelected()
            Dim nrow As Integer = Bs1.Position
            Dim col As String = PKColumnName
            PKOfCurrentRow = (Bs1(nrow).Item(col))
        End Sub

    where Bs1 is a bindingSource,  PKOfCurrentRow is Integer

    The error is Option Strict On disallows late binding

    Thanks for help

    Monday, June 25, 2018 3:58 PM

Answers

  • The default Item property on BindingSource returns an Object type; you need to cast it into whatever type object your BindingSource is bound over.  If it is bound to a DataTable then the underlying type will be DataRowView.  Use CType to get the correct type.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Claudio111 Monday, June 25, 2018 8:28 PM
    Monday, June 25, 2018 5:06 PM
    Moderator

All replies

  • The default Item property on BindingSource returns an Object type; you need to cast it into whatever type object your BindingSource is bound over.  If it is bound to a DataTable then the underlying type will be DataRowView.  Use CType to get the correct type.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Claudio111 Monday, June 25, 2018 8:28 PM
    Monday, June 25, 2018 5:06 PM
    Moderator
  • solved

    thank youReed

    Monday, June 25, 2018 8:28 PM