This is probably a relatively easy thing to do but I’m trying to get OCR text and see if a screen contains words, e.g “word” or “another”.
How would I go about doing this? I’ve tried Screen.Contains(“Word”) OR (“Another”) however I get the error of “Option Strict On disallows implicit conversions from ‘String’ to ‘Boolean’.” and Contains is not a member of ‘Boolean’
The “Screen” variable is currently in the Text Output (as opposed to WordsInfo Output).
It sounds like you have somehow got the incorrect format for the Screen variable. This should be a String format in which case you will be able to do .String. The error message is implying that your Screen variable is a Boolean in which case you cannot use Contains or other text functions.
Sorry, my bad! The error I get when it’s String is “Option Strict On disallows implicit conversions from ‘String’ to ‘Boolean’.” and when I change it to Boolean, I get the “Contains is not a member of ‘Boolean’” error.
If it makes any difference, this is a condition on an “If” function
So where you have the variable as string the message is telling you that you are trying to convert string to boolean. Can you post your xaml file please? This should be an easy fix.
There is, but you need to reverse the check and see if you have any element with a predicate.
List(Of String) keywords = {"word", "another"} keywords.Any(Function(x) yourText.Contains(x)) // yourText contains any of the keywords in the list keywords.All(Function(x) yourText.Contains(x)) // yourText contains all of the keywords in the list
Which essentially is a loop as well, but can be used in an If condition directly.
Sidenote: @Short - “Screen” is a bad name for a variable, since there actually is a class named like that in a couple of namespaces and you could get conflicts. Try to name your variables more descriptively, f.e. screenReadout or screenText etc.