---
title: "Object reference not set to an instance of an object"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/166366-object-reference-not-set-to-an-instance-of-an-object"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Travoni"
published: "2007-11-14T12:28:31.000Z"
updated: "2007-11-14T12:58:15.000Z"
replies: 2
views: 447
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/166366-object-reference-not-set-to-an-instance-of-an-object"
---

# Object reference not set to an instance of an object

## #1 — Travoni, 2007-11-14T12:28Z

```
Dim lines() As String
            Dim fields() As String
            Dim li As ListItem = Nothing
            lstValues.Items.Clear()
            lines = "Ett:1|Två:2|Tre:3".Split(CChar("|"))

            For i As Integer = 0 To UBound(lines)
                fields = lines(i).Split(CChar(":"))
          [red]      li.Text = fields(0)[/red]
                li.Value = fields(0)
                lstValues.Items.Add(li)
            Next i
```

På denna rad:  li.Text = fields(0)

Permalänk: https://www.webforum.nu/p/166366

## #2 — andreas_lindh, 2007-11-14T12:52Z

lägg till li = new listitem

```
For i As Integer = 0 To UBound(lines)
  li = new listitem
  fields = lines(i).Split(CChar(":"))
  li.Text = fields(0)
  li.Value = fields(0)
  lstValues.Items.Add(li)
Next i
```

Permalänk: https://www.webforum.nu/p/2051558

## #3 — Travoni, 2007-11-14T12:58Z

Åhhh, nej ett sånt nybörjarfel... Tack!

Permalänk: https://www.webforum.nu/p/2051559

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/166366-object-reference-not-set-to-an-instance-of-an-object
