VB.NET-Quellcode
- Imports System.IO
- Module Data
- Public DataFile As String = "C:\Users\" & Environment.UserName & "\Documents\Einkaufsplaner\"
- Public ItemMap As Dictionary(Of Integer, List(Of String))
- Public CategoryList As List(Of String)
- Sub Load()
- Dim Category As String = DataFile & "Categorylist.txt"
- If File.Exists(Category) = False Then
- Try
- File.Create(Category)
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- Application.Restart()
- Try
- CategoryList = File.ReadAllLines(Category, System.Text.Encoding.Default).ToList
- Catch ex As Exception
- MsgBox(ex.Message)
- Return
- End Try
- Else
- Try
- CategoryList = File.ReadAllLines(Category, System.Text.Encoding.Default).ToList
- Catch ex As Exception
- MsgBox(ex.Message)
- Return
- End Try
- End If
- For i As Integer = 0 To CategoryList.Count - 1
- Dim filename As String = DataFile & CategoryList(i) & ".txt"
- Dim itemlist As List(Of String)
- If File.Exists(filename) = False Then
- Try
- File.Create(filename)
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- Else
- itemlist = File.ReadAllLines(filename).ToList
- ItemMap.Add(i, itemlist)
- End If
- Next
- End Sub
- End Module
Ich verstehe nicht wieso es an der Stelle ItemMap.Add(i, itemlist) ein NullPointer ist bitte um Hilfe
Arayni.setExperience(Experience.Beginner)
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „arayni“ ()