I’m looking at an existing project, trying to make sense of something that VB.NET is doing or allowing:
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Session("UserID") Is Nothing Then
Response.Redirect("~/AccessDenied.aspx")
Exit Sub
End If
' Variables
Dim oNotes As New VistaClaims.ClaimsInfo.NoteDB
Dim DSNotes As New DataSet
Dim dgNotes As DataGrid = dgNotes
Dim oRecoveries As New VistaClaims.ClaimsInfo.RecoveryDB
Dim oBills As New VistaClaims.ClaimsInfo.PaymentDB
Dim oSubro As New VistaClaims.ClaimsInfo.SubroDB
Dim DSRecoveries As New DataSet
Dim DSBills As New DataSet
Dim DSSubro As New DataSet
'Dim dgBills As DataGrid = dgBills
'Dim dgRecoveries As DataGrid = dgRecoveries
The issue I have is with the line Dim dgNotes As DataGrid = dgNotes
.
I tried commenting it out, thinking it was defined on the ASP.NET WebForm, but it was not and I got errors.
I’ve done more C# development, and often VB.NET does things that I think should be illegal – but they work.
The code works. There is no error that I know of. I just happened to open this particular form on an old project today, and I thought I’d resolve the possible (likely, it seems to me) null reference exception.
What is that line of code doing? I don’t understand.
4