Interesting...
You want to be able to seperate out the path into seperate variable depending on 1 out of 4 situations.
I am going to type out the answer in C# but should be easy for you to convert to
VB. I will also try to adhoc some
VB but keep in mind I can ready it but never really tried to write it hehe.
First thing you want to do is determine what scenario you are dealing with. Feel free to shoot me down if I am stray from what you are trying to do.
I see you have "()" around the defining property index for ServerVariables. It is a property and should use "[]" instead, but if that part is working then above must just be a type hehe.
Start but seperating out all the strings.
string[] arrMyString = strPagePath.Split('//'); //This will split path up into an array split by the backslashes.
Next, you will want to get the string count. Reason being for 2 reasons. One reason is you kave a set number of instances so this gives you something static to look for. You can only have an array that can have 2, 2, or 4 items inside of it. This will be easier handled by a switch statement.
switch(arrMyString.Count)
{
case 2:
strMainDir = arrMyString[0];
strPageId = arrMyString[1];
break;
}
Declare the string variables before the switch statement or they will go bye bye after you exit switch block if declared inside.
For the other cases just start from 3 and go up to 4. I personally think it would be cool to leave it in the array and pull what you need from there. I hope that made sense. I tend to shorthand a lot when I post versus speaking it hehe.