Wartość "<nullconstant>" nie jest zadeklarowana

Wartość "<nullconstant>" nie jest zadeklarowana. Stała null nie jest już obsługiwana; Zamiast tego należy użyć elementu System.DBNull.

Instrukcja używa słowa kluczowego Null , które nie jest już obsługiwane w języku Visual Basic.

Identyfikator błędu: BC30822

Aby poprawić ten błąd

  1. Użyj DBNull zamiast Null. W poniższym przykładzie pokazano to.

    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. Użyj słowa kluczowego Nothing dla przypisań i porównań podczas używania zmiennych obiektów. W poniższym przykładzie pokazano to.

    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  
    

Zobacz też