VB.NET Split() Function Help

Posted on 2011-04-30
Medium Priority
Last Modified: 2012-06-27
I have a variable strStringToBeSplit which contains the following string (quotes included in the string): "\\esxvm1.facultystaff.local\Memory\Memory Overcommit (1 Minute Avg)"

I split this string using the \ character as the delimiter.

I expect the second value in the array storing the split text to return this string (quotes excluded): "esxvm1.facultystaff.local"

The second value of my array always comes up empty. What am I doing wrong?

Dim myValue As String = strStringToBeSplit
Dim strSplitValues() As String = Split(myValue, "\")
txtTextBox.Text = strSplitValues(1) ' comes out blank
Question by:mbritojr
  • 2
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 35499337
The value you want is at the third slot (index #2).  The first and second value are blank because there is nothing in front of the first slash, and nothing between the first and second slash, so they are empty strings.

Author Comment

ID: 35499437
Ahhhhh, two \'s there...obviously been staring at this code too long. Thanks for that.

Author Closing Comment

ID: 35499439

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question