VB.NET Split() Function Help

Posted on 2011-04-30
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
    LVL 85

    Accepted Solution

    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.
    LVL 1

    Author Comment

    Ahhhhh, two \'s there...obviously been staring at this code too long. Thanks for that.
    LVL 1

    Author Closing Comment


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    A short article about problems I had with the new location API and permissions in Marshmallow
    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…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now