Visual Basic: indexoutofrangeexception help needed in my code for unique word counter

Tags:
Visual Basic
Hey, at school we got assigned to make a unique word counter in VB and I kept getting the indexoutofrangeexception and I have no idea why, here is my code:
Public Class Form1

Private Sub BtnEnter_Click(sender As Object, e As EventArgs) Handles BtnEnter.Click
Dim Input, Word() As String
Dim Count, Index, Index2, Unique As Integer

Input = TxtInput.Text
Word = Input.Split(CChar(" "))
Count = Word.Length
Unique = Count
Index = 0
Index2 = 0
Count = Count + 2

For Index = 0 To Count - 1
For Index2 = 0 To Count - 1
If Word(Index - 1) = Word(Index2 - 1) Then
Unique = Unique - 1
Index = Index + 1
Index2 = Index2 + 1
End If
Next
Next

MsgBox("Words: " & Count - 1 & " Unique: " & Unique)
End Sub
End Class
Help would be great!
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: