Results 1 to 2 of 2

Thread: das objekt mit null wert muss einen wert haben

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2024
    Posts
    66

    das objekt mit null wert muss einen wert haben

    hello,

    I have the following code and in the red line i recieve this message.
    das objekt mit null wert muss einen wert haben
    how to fix it?

    Code:
    If Flag2 = True Then
        Root.Expand()
        For i = 0 To RootNodes.Count - 1
            RootNodes.Item(i).Expand()
            Dim RootItemsfori = Root.Nodes.Item(i).Nodes
            For j = 0 To RootItemsfori.Count - 1
                RootItemsfori.Item(j).Expand()
                Dim RootItemsforj = Root.Nodes.Item(i).Nodes.Item(j).Nodes
                For k = 0 To RootItemsforj.Count - 1
                    RootItemsforj.Item(k).Expand()
                    Dim RootItemsforw = Root.Nodes.Item(i).Nodes.Item(j).Nodes.Item(k).Nodes
                    For w = 0 To RootItemsforw.Count - 1
                        Dim cNI = TryCast(RootItemsforw.Item(w).Tag, RiskeySIITreeBuilder.NodeInfo)
                        If Not cNI.Key.UnterStArt.Value.ToString() Is Nothing Then
                            RootItemsforw.Item(w).Expand()
                        Else
                            Exit Sub
                        End If
                    Next
                Next
            Next
        Next

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,803

    Re: das objekt mit null wert muss einen wert haben

    FYI - Anytime you have Not {expression} Is Nothing, you can rewrite it to {expression} Is Not Nothing. It makes it easier to read in my opinion.

    But if I understand it correctly the error message correctly (because it isn't in English and I'm relying on translate), you're attempting to access a value that doesn't exist. This is probably because one of the many chained properties/methods is returning nothing and you should only get the next property/method if the one before it isn't null. Maybe something like this:
    Code:
    cNI?.Key?.UnterStArt?.Value?.ToString()
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width