Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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*"

  • Leaders
Posted

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.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...