emi_sastra
asked on
STRING CONTAINS
Hi All,
I have a string and I want to compare if in ("A", "B", "C").
I try VariableA.Contains("A", "B", "C"), it does not work.
How could I do it using string.contains ?
Or there are other ways to do it ?
Thank you.
I have a string and I want to compare if in ("A", "B", "C").
I try VariableA.Contains("A", "B", "C"), it does not work.
How could I do it using string.contains ?
Or there are other ways to do it ?
Thank you.
ASKER
VariableA.Contains(strToCo mpareVaria ble)
The strToCompareVariable is already "A", "B", "C", and I get it from a function.
Is there any simple ways to do it ?
Thank you.
The strToCompareVariable is already "A", "B", "C", and I get it from a function.
Is there any simple ways to do it ?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you give me the value of VariableA and strToCompareVariable?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've got error :
Error 1 Expression of type 'String' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider.
Thank you.
Error 1 Expression of type 'String' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider.
Thank you.
Can you post the code?
ASKER
This is the code that throw compile error.
Dim VairableA As String = "JosephOcena"
Dim Search() As Char = "A,B,C"
Dim result = (From letter In VairableA.ToUpper _
Where Search.Contains(letter)).C ount
Thank you.
Dim VairableA As String = "JosephOcena"
Dim Search() As Char = "A,B,C"
Dim result = (From letter In VairableA.ToUpper _
Where Search.Contains(letter)).C
Thank you.
Add an Import statement for the System.Linq, System.Data.Linq, or System.Xml.Linq namespace to your code file. You can also import namespaces for your project by using the References page of the Project Designer (My Project).
ASKER
- Dim result = (From letter In VairableA.ToUpper _
Where Search.Contains(letter)).C ount
What is letter here ?
Thank you.
Where Search.Contains(letter)).C
What is letter here ?
Thank you.
Do you mean
"A,B,C".Contains(VariableA )
?
"A,B,C".Contains(VariableA
?
ASKER
I mean VariableA,contains(strToCo mpareVaria ble)
VariableA could be any string.
strToCompareVariable="A, B, C", yet strToCompareVariable could any string too.
Thank you.
VariableA could be any string.
strToCompareVariable="A, B, C", yet strToCompareVariable could any string too.
Thank you.
ASKER
Hi All,
Thank you very much for your help.
Thank you very much for your help.
If variableA.Contains("A") then
'Do something here
End if
If variableA.Contains("B") then
'Do something here
End if
If variableA.Contains("C") then
'Do something here
End if