JumpyNET Posted February 24, 2013 Posted February 24, 2013 Googling for instructions spesific to Windows Phone seems impossible. Can someone please help me how to replace the following VB-code with WP alternatives? Dim Beginning As String = Left("Some Text", 2) Dim Answer As Boolean = "Some Text" Like "S*" Quote
Leaders snarfblam Posted February 24, 2013 Leaders Posted February 24, 2013 Non-VB-specific methods are generally recommended anyways since they're generally the same across all .NET languages. To get the left part of a string: ' Get left two letters Dim start As Integer = 0 Dim length As Integer = 2 Dim Beginning As String = ("Some Text").Substring(start, length) As for the "Like" operator, I've never used it but it seems to me that regular expressions would be a good substitute, if you're willing to learn it (not difficult). Dim regexMatch As Boolean = Regex.IsMatch("Some Text", "^S.*") The dot matches any character, and the asterisk modifies the dot to match zero or more any-characters (i.e. ".*" in regex behaves just like "*" in your code). The ^ matches the start of the string. I also stumbled onto this article taking a different approach. Quote [sIGPIC]e[/sIGPIC]
JumpyNET Posted February 25, 2013 Author Posted February 25, 2013 Your thorough response is much appreciated. Thank you. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.