VB .net and string

Posted on 2012-08-20
Last Modified: 2012-08-20
Hey Guys

I have a string that i need to remove all information after the equal sign. an example of my string is below. so what i am trying to do is when it is done parsing it would only show T1. i would use the char count but i cant because i will have up to 4 characters in the begining. any ideas?

T1 = Testing Instance 1
T123 = Testing Instance 123
Question by:Chris_Ware
    LVL 74

    Accepted Solution

    Dim result As String = source.Substring(0, source.IndexOf("="c)).Trim()

    Open in new window


    Author Closing Comment

    that was quick :)
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    You can also use Split():
    Dim result As String = source.Split("="c)(0).Trim()

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    760 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

    15 Experts available now in Live!

    Get 1:1 Help Now