Partilhar via


não está declarado como '<nullconstant>'

Mensagem de erro

não está declarado como '<nullconstant>'.Não há mais suporte para a constante nulo; use sistema.DBNull.

Uma demonstrativo usa o Null palavra-chave, que não é mais suportado no Visual Basic.

ID de erro: BC30822

Para corrigir este erro

  1. Use DBNull em vez de Null.O exemplo a seguir demonstra isso.

    Sub TestDBNull()
        Dim t As DataTable
        ' Assume the DataGrid is bound to a DataTable.
        t = CType(DataGrid1.DataSource, DataTable)
        Dim r As DataRow
        r = t.Rows(datagrid1.CurrentCell.RowNumber)
        r.BeginEdit
        r(1) = System.DBNull.Value ' Assign DBNull to the record.
        r.EndEdit
        r.AcceptChanges
        If r.IsNull(1) Then
            MsgBox("")
        End If
    End Sub
    
  2. Use o Nada (Visual Basic) palavra-chave para atribuições e comparações quando você usa variáveis de objeto. O exemplo a seguir demonstra isso.

    Sub TestNothing()
        Dim cls As Object
        ' cls is Nothing if it has not been assigned using the New keyword.
        If (cls Is Nothing) Then
            MsgBox("cls is Nothing")
        End If
        cls = Nothing ' Assign Nothing to the class variable cls.
    End Sub
    

Consulte também

Conceitos

Sumário para programação de mudanças em elementos de suporte

Referência

DBNull

Nada (Visual Basic)