vb.net - String.Contains not working as expected -


i have 54,000 files each different method of naming , need check whether filename contains particular string. however, can't find ways of getting select statement work correctly.

my code fails unexpectedly. please can tell me why string "bar" not found in "baritone"?


dim tempcheck string = "1st baritone" dim goodone boolean = false select case tempcheck     case tempcheck.contains("corn")         goodone = true     case tempcheck.contains("horn")         goodone = true     case tempcheck.contains("bar")         goodone = true     case tempcheck.contains("trom")         goodone = true     case tempcheck.contains("eup")         goodone = true     case else         goodone = false end select 

try this:

    dim tempcheck string = "1st baritone"     dim goodone boolean = false     select case true         case tempcheck.contains("corn")             goodone = true         case tempcheck.contains("horn")             goodone = true         case tempcheck.contains("bar")             goodone = true         case tempcheck.contains("trom")             goodone = true         case tempcheck.contains("eup")             goodone = true         case else             goodone = false     end select 

select case doesn't work on strings (you have compare string string, in case compare boolean). work on booleans compared booleans


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -