Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42466

Dictionary problems

$
0
0
What i am trying to do here is to replace words with others and add it to the listbox after all the strings have been replaced (if they are in the dictionary)

The error i am getting is "Object Reference not set to an instance of an object"


Public Sub PopulateFixDictionary()
Code:

Public Sub PopulateFixDictionary()
        fixDictionary = New Dictionary(Of String, String())
        Dim words = My.Resources.words

        For Each Str As String In words.Split(",")
            fixDictionary.Add(Str, Nothing)
        Next
    End Sub

Public Sub Fixer()
Code:

Public Sub Fixer()
        Try
            lst_after.Items.Clear()
            Dim di As New IO.DirectoryInfo(My.Settings.path)
            Dim aryFi As IO.FileInfo() = di.GetFiles(FileExt)
            Dim fi As IO.FileInfo
            Dim fs As IO.FileInfo
            For Each fi In aryFi
                Dim f2 As String
                Dim f3 As String
                f2 = fi.Name
                For Each fixWord As String In fixDictionary.Keys
                    If (f2.Contains(fixWord)) Then
                        Dim value As Integer = fixDictionary.Item(fixWord).Length
                        Dim replacement As String = fixDictionary.Item(fixWord)(value)
                        f3 = Replace(f2, fixWord, replacement)
                        lst_after.Items.Add(f3)
                    End If
                Next
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub



I really hope someone can help me

Viewing all articles
Browse latest Browse all 42466

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>