F flyingbag Member Licensed User Longtime User Sep 14, 2012 #1 Hi I am trying to do something like the following: Code: Copy Select sMsg Case sMsg.Contains("MyString") <DoSomethingHere> However - it does not work. Any way to do this using Select Case? I tried Case ( sMsg.Contains("MyString") ) - but that doesnt work too Thanks flyingbag
Hi I am trying to do something like the following: Code: Copy Select sMsg Case sMsg.Contains("MyString") <DoSomethingHere> However - it does not work. Any way to do this using Select Case? I tried Case ( sMsg.Contains("MyString") ) - but that doesnt work too Thanks flyingbag
klaus Expert Licensed User Longtime User Sep 14, 2012 #2 Try this one: Code: Copy Select True Case sMsg.Contains("MyString") <DoSomethingHere> sMsg is a string but sMsg.Contains("MyString") returns a boolean. That's the reason why it doesn't work. Best regards. Upvote 0
Try this one: Code: Copy Select True Case sMsg.Contains("MyString") <DoSomethingHere> sMsg is a string but sMsg.Contains("MyString") returns a boolean. That's the reason why it doesn't work. Best regards.
F flyingbag Member Licensed User Longtime User Sep 14, 2012 #3 Thanks for the quick response ... Logically it does make sense I tried this with Select True, but it doesnt work... CORRECTION : I think i have some other problems in my code for now ... will try this again and revert ( it should work) Sorry about the wrong post earlier Last edited: Sep 14, 2012 Upvote 0
Thanks for the quick response ... Logically it does make sense I tried this with Select True, but it doesnt work... CORRECTION : I think i have some other problems in my code for now ... will try this again and revert ( it should work) Sorry about the wrong post earlier
klaus Expert Licensed User Longtime User Sep 14, 2012 #4 It does work, I tried it before posting it. Best regards. Upvote 0
F flyingbag Member Licensed User Longtime User Sep 14, 2012 #5 Apologies Klaus, works fine... The "echo" from my server and the string i was trying to Match was different - hence it was failing (as i said - problem in my code) Thank you! Upvote 0
Apologies Klaus, works fine... The "echo" from my server and the string i was trying to Match was different - hence it was failing (as i said - problem in my code) Thank you!
R Roger Garstang Well-Known Member Licensed User Longtime User Sep 17, 2012 #6 Interesting usage of a Select Case. Sort of Turns it into a If/Else If Block which I would have suggested as the proper one to use, but this one appears to work better when methods are involved with less code and less compares. I wonder which way compiles and executes the best/faster? Upvote 0
Interesting usage of a Select Case. Sort of Turns it into a If/Else If Block which I would have suggested as the proper one to use, but this one appears to work better when methods are involved with less code and less compares. I wonder which way compiles and executes the best/faster?