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

System.NullReference Exception

$
0
0
Keep getting these errors pop up and i cant seem to fix it. Im currently doing a project to make a Spell Checker. I have imported a .txt of 60,000 words to compare against. If there word is good then it will come back as a msg box saying found. I just cant seem to get the program to run and i am not sure if i have increment the array properly. Hope someone can help me. Thanks in advance. My cose is below...

Code:

Public Class Form1

    'Code for Spell Checker, Created by Murray Hart'
    'Version1 - 08/11/2012'
    'Global Variables'

    Dim i As Integer
    Dim arrayWords(i) As String
    Dim foundWord As Boolean

    Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click

        'Code for the check button'
        Dim wordList As String = My.Computer.FileSystem.ReadAllText("test.txt")
        Dim searchedChar As String = vbCrLf
        Dim start As Integer
        Dim finish As Integer
        Dim stringLength As Integer = Len(wordList)

        'Declare start number for counting and index for the arrayWords'
        i = 0
        start = 1

        'Search for enter keys to split words in single strings'
        'loop untill words are one by one in the array'
        While i > Len(wordList)
            finish = InStr(start, wordList, searchedChar, CompareMethod.Text)
            i &= +1
            arrayWords(i) = Mid(wordList, start, finish - 1)
            start = finish + 2
        End While

        'Call sub routine to search for the entered word'
        Call checkWord()

    End Sub

    Private Sub checkWord()

        'Code for search routine'
        Dim enteredWord As String = txtInput.Text

        'Set found statud to false until found'
        foundWord = False

        For Each Str As String In arrayWords(i)
            If Str.Contains(enteredWord) Then
                MsgBox("Found " & enteredWord)
            End If

        Next
    End Sub



End Class


Viewing all articles
Browse latest Browse all 42728

Trending Articles



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