If you need to parse just a few characters from a string, you can easily do that in the code-behind like this:
MyVariable = VariableName.Substring(1,3)
This gets the first through the third character in the string and places it in MyVariable. Note that the starting position of the variable is 0 so the true first characters would be picked up if you used VariableName.Substring(0,3).
Some times you need to figure out what the actual file name is a the web page that you are on. If this is the case, here is the easy way to do this in the code behind:
Dim myPage As String = System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath)
If you are on a page, myPage will have just the page name in it (i.e. for the default page the value would be default.aspx).
Sometimes you may want to change the ShowStartNode or StartNodeOffset for your sitemap file when the page is loaded in vb.net. One example is if you are using the web.sitemap file to display an asp:menu on your page. There may be certain pages that you want to show from the starting node and other times you do not.
To do this, you must place the code in under your Page_Init because it will get loaded to late if you put it in Page_Load. Here is a quick example.
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Dim myPage As String = System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath)
If myPage = "Default.aspx" Then
SiteMapDataSource1.ShowStartingNode = "False"
SiteMapDataSource1.StartingNodeOffset = 2
Else
SiteMapDataSource1.ShowStartingNode = "False"
SiteMapDataSource1.StartingNodeOffset = 1
End IfEnd Sub