Hi,

I'm comparing String with array of Strings and I got this error

Object reference not set to an instance of an object.

This is my code:

For Each Str As String In Word
                    If Str.Contains(w1) = False Then

                        MsgBox(w1 & _
                          Str.IndexOf(w1))
                        out += 1
                    End If
                Next

The error in this line:

If Str.Contains(w1) = False Then

Any one have an idea??

thanks in advance.

What is wl ? It is looking for an object to be there, but is not finding one.

Edited 5 Years Ago by bklynman01: gramatical error...

w1 is a string and I know it's looking for an object and not finding it but how I can fix it???:(

Hi again
I think the cause of my error is that i set the Strings of the array in a sub class and call the array in another sub class

Edited 5 Years Ago by Maha Sh.: n/a

I solved my error :icon_cheesygrin:

The problem was I left the array empty in the public class because it should be filled by the user ,and when the user click on the help button which will search on the array while it's empty the error occur. So I just filled the array in the public class .

:$ I am just a beginner in VB


Thanks bklynman01 for your reply it was helpful :)

This question has already been answered. Start a new discussion instead.