0

I probably got an easy question for you but I haven't got the answer yet.

what I want is:

compare string1 with string2, which I built via a code before (not essential for the question), and if the string2 is not essential, I use a wildcard to fit every string1 in string2.

what I tried is:

string1= "whatever the case may be"
string2= "*"
LikeOperator.LikeString(string1, string2, Microsoft.VisualBasic.CompareMethod.Binary)

My wildcard is not working properly. it doesn't give a "true" back. What am I doing wrong there?

Vinay Pandey
  • 8,589
  • 9
  • 36
  • 54
flyingAlemannian
  • 175
  • 2
  • 13
  • Have a look at string.contains: https://msdn.microsoft.com/en-us/library/dy85x1sa(v=vs.110).aspx – Paul Michaels Feb 21 '18 at 10:36
  • 1
    Can you share that `code`? – FaizanHussainRabbani Feb 21 '18 at 10:38
  • 2
    https://stackoverflow.com/questions/30299671/matching-strings-with-wildcard/30300521#30300521 – Dmitry Bychenko Feb 21 '18 at 10:40
  • @FaizanRabbani, no I can't it's property of my company. sorry. But as I told you, not needed for my question because I will get a string as a result. To be more clear about: HOW to fit every string in a comparison? I just found sth. like "contains" but I dont want to proof if sth contains I want to tell the code "use every possible string" – flyingAlemannian Feb 21 '18 at 10:51
  • 2
    *if the string2 is not essential, I use a wildcard to fit every string1 in string2* I've read this sentence at least 4 times now and I have literally no idea what it is trying to portray. Please try and explain yourself more clearly as it stands I do no understand this question at all – Liam Feb 21 '18 at 10:53
  • @LocEngineer btw. Asking is the thing which made us human beeing also to that what we are now. We can communicate better than other species on earth. But jsut if the guy who doesnt understand, asks. Otherwise we stay stupid – flyingAlemannian Feb 21 '18 at 10:54
  • 1
    Is this ^ a riddle? – Liam Feb 21 '18 at 10:54
  • @Liam maybe not the best sentence to be honest. But nevertheless, The focussed question is: "how to fit a string in any other string by using a wildcard" – flyingAlemannian Feb 21 '18 at 10:57
  • @Laurin: still not really clear. Please provide an expected outcome. Do you want a list of matches or the best fit or what? In any case: Dmitry's link provides a pretty good starter I think. Would that fit your purpose? – LocEngineer Feb 21 '18 at 10:59
  • @LocEngineer there we go, now I know what you need. this boolean is anchored in a if-clause. I got some checkboxes. to be simple, if that is possible anymore, if the checkbox is clicked (true) then use the string in the combobox next to and compare it with a string out of a DataTable, if false use a wildcard to match every string from the table. clearer? – flyingAlemannian Feb 21 '18 at 11:05
  • 2
    Yes. Then use the solution from Dmitry's link for your wildcard match. The RegEx solution is pretty much the most suitable approach I think. – LocEngineer Feb 21 '18 at 11:07
  • @LocEngineer,@pm_2, thanks. btw there are guys which are calling me "the riddler" – flyingAlemannian Feb 21 '18 at 11:11

1 Answers1

0

And the answer is:

You can't use wildcards on NULL-values. Workaround is, to write "" into the string if it is NULL.

Now it works the way I posted it right on top.

flyingAlemannian
  • 175
  • 2
  • 13