I'm using .Contains but it doesn't work


Above are the values ​​of the two variables, it is possible to see that the content of the select certificate is contained in the selected_certificate, but the if condition is never true…why?
image

Hey

can you try with

certificado_selecionado.Trim().ToUpper.Contains(seleciona_certificado.Trim().ToUpper)

Regards

it worked, can you give me a brief explanation of why?

thanks

Hey

when you use contains without a specific format such as .ToLower or .ToUpper, it will look for exactly the text that you have inside the quotes, if you use .Contains(“test”) it will look for it exactly like this, that is, if there is Test within your string ( a small variation like the initial capital letter) will not find it since it is not exactly the case you are looking for, that is why everything is converted to the same format that the comparison is the same, in our case we use .ToLower (we convert everything to lower case) or .ToUpper (we convert everything to upper case) and thus have a comparison of the same case and more reliable

Regards!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.